get json specific value in javascript from json file -


i have json.json file this

{"name1":"hallo","name2":"defy","name3":"carm","name4":"disney"} 

and script im using read file

<script type='text/javascript'> $(window).load(function(){ $.getjson("json.json", function(person){ $.each(person, function(key, value) {document.write(key+"= "+value+"<br />");  }); }); }); </script> 

this script made poin out of data need "name3" value stored +value+

how that?

you dont need iterate then:

$.getjson("json.json", function(person){     document.write("name3=" person.name3); }); 

i'd stray away document.write , append container.

<div id="test"></div>  $.getjson("json.json", function(person) {     $("#test").append("<span> name3= " + person.name3 + </span>"); }); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -