javascript - Issue with $.each in jquery -
javascript - Issue with $.each in jquery -
ok have issue when seek utilize $.each iterate through json. i'm trying access posts information.
this code far.
var newposts = <? echo(getposts($optionsarray)); ?>; var postjson = json.parse(json.stringify(newposts)); console.log(postjson); alert(postjson); //make sure div emptied before append $("#posts").empty(); //append new info $.each(postjson.posts, function(key, value){ alert(value); })
the console log displays info want no info alert. nil pops up. been crackin @ bit.
json.parse = turns formatted json string , creates object... json.stringify = turns javascript object json string....
so turning string , object. rid of json.parse if want print out string properly. should this:
var jstring = json.stringify(newposts); alert(jstring);
javascript jquery json
Comments
Post a Comment