javascript - How to Read JSON file and Modify JQuery -


i have following code: http://jsfiddle.net/wg2yb/ reads local file (.txt, .json...) , displays content.

i want able have not read, modify things. have json file looks bit this:

{ "height":100,  "layers":[         {          "data":[0, 0, 0, 0...];          "height":100,          ...         } } 

i want know how modify page's jquery based on that. if layers height set 100 in json file, like:

$('#map').css('height','100px');  

look json.parse turn data more javascript friendly.

with can save result javascript object , check properties/array values , manipulate html elements:

var data = json.parse(this.result); if (data.layers && data.layers.length && data.layers[0].height) {     document.getelementbyid('map').style.height = data.layers[0].height + 'px'; } 

check out on jsfiddle.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -