javascript - Load json from file uploaded -


i have file input , submit button. file uploaded contains json needs loaded in view, (a graph display). don't need store file, visualize it.

is there way using jquery, javascript or angular? application included static content inside spring app, has function standalone app also.

actually can load file server or make request rest endpoint, need add option load local file json data.

thanks in advance

this work ie >= 10. aware there no fault handling implemented. i'll leave ;)

html:

<input type="file" id="file" name="file"> <button type="submit" id="button">click!</button> 

js (jquery):

$('#button').on('click', function() {     var reader = new filereader();     var file = $('#file').get(0).files[0];     reader.onload = function(e) {         console.log(json.parse(e.target.result));     };     reader.readastext(file); }); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -