I am having a problem trying to alert the json data.
Here is the code part:
$.getJSON("http://myurl/api/get_data", function(data){
var output = '';
$.each(data, function(index, value){
alert(data); // returns object
alert(value.myurl) //Here is the problem - returns undefined
});
Here is the json data it’s reading:
{"myurl":"http://somedomain.com/"}
How can I get the alert to return the value?
You are thinking too complicated. JSON stands for JavaScript Object Notations. It’s basically the javascript syntax representation of the object it contains.
The value passed to the success handler of getJSON is already the unpacked object. So you can just do this: