在回调函数中访问JSON数据结构

在回调函数中访问JSON数据结构,json,callback,getjson,Json,Callback,Getjson,我从Yahoo API返回了以下数据结构: cbfunc({ "query": { "count": 1, "created": "2011-02-16T00:48:51Z", "lang": "en-US", "results": { "place": { "woeid": "2487956" } } } }); 在我

我从Yahoo API返回了以下数据结构:

cbfunc({
    "query": {
        "count": 1,
        "created": "2011-02-16T00:48:51Z",
        "lang": "en-US",
        "results": {
            "place": {
                "woeid": "2487956"
            }
        }
    }
});
在我的代码中,我尝试按如下方式访问它:

$.getJSON(url,function(json)
{
    $.each(json.query.results.place, function(i, item)
    {
        alert(item.woeid);
    });
});

但它不起作用。任何帮助都将不胜感激。谢谢。

我问这个问题还为时过早。我进行了如下ajax设置:

$.ajaxSetup({"error":function(XMLHttpRequest,textStatus, errorThrown) {   
        alert(textStatus);
        alert(errorThrown);
        alert(XMLHttpRequest.responseText);
    }});
一切都被修复了。好吧,至少我发现有一个解析错误,然后重新格式化了数据


很抱歉发了这个帖子

我认为这是JSONP而不是JSON。通过编写一个名为cbfunc的函数,可以对返回的json使用eval