Jump to content

looping over json object


skaterdav85

Recommended Posts

I encoded one of my php arrays into a json object using json_encode. I return the json object to my function that made the ajax call, but I am not sure how to loop over the json. This is my first time using json so im not really sure how to do it. I alerted the response back and my json object looks like this:["52.0190289,-0.7704274","52.0190289,-0.7704274","51.95237,-1.72013","34.6937378,135.5021651","40.7306,-73.98658","33.66754,-111.86543"]

Link to comment
Share on other sites

JSON is the native array and object syntax for JavaScript, so you can just evaluate the string to get an array, and use that normally.

Link to comment
Share on other sites

oh ok. i never saw the point of eval() until now. Before I was dealing with just string data being returned from an ajax call, but now that I have json, evaluating my string makes it easier to work with. I am actually using jquery to make the ajax request and i just found out that i can specify the data type being returned as either xml, html, or json. anyways, thanks for the clarification!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...