I have the following data structure returning from a Yahoo API:
cbfunc({
"query": {
"count": 1,
"created": "2011-02-16T00:48:51Z",
"lang": "en-US",
"results": {
"place": {
"woeid": "2487956"
}
}
}
});
In my code, I'm trying to access it as follows:
$.getJSON(url,function(json)
{
$.each(json.query.results.place, function(i, item)
{
alert(item.woeid);
});
});
but it is not working. Any help would be muc开发者_如何学编程h appreciated. Thank you.
I was premature in asking this question. I did an ajax setup like so:
$.ajaxSetup({"error":function(XMLHttpRequest,textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown);
alert(XMLHttpRequest.responseText);
}});
and everything was fixed. Well, at least I found out that there was a parse error and then reformatted the data!
Sorry for the post!!!
I think it is JSONP and not JSON. you could've used an eval on the returned json, by writing a function called cbfunc.
精彩评论