javascript - Build a list with JSON and jQuery -
i need build list using parameters "name" taken file "sendjson.php" (in json, of course). how can create list using jquery one?
<div id="firstresultname">firstresultname</div> <div id="secondresultname">secondresultname</div>
i don't know how result possible detect , write right number on div? thanks!
$.each(json, function(key, value){ $("body").append('<div id="'+value+'">'+value+'</div>'); });
or just
$.each(json, function(key, value){ $("body").append('<div>'+value+'</div>'); });
to retreive json & proccess, following
$.ajax({ 'url' : 'yoururl.php', datatype: 'json', success: function(json){ $.each(json, function(key, value){ $("body").append('<div>'+value+'</div>'); }); } });
Comments
Post a Comment