getJson中没有返回任何内容,但在Chrome窗口中没有响应

时间:2012-01-08 01:44:05

标签: jquery json getjson

我正在使用此代码:

$.getJSON(url, function(data) {
                console.log(data);
            }, "json");

现在,控制台中没有记录任何内容,但我可以在Chrome的网络标签中看到响应。这有什么理由吗?回调是错误的吗?

1 个答案:

答案 0 :(得分:1)

最后摆脱, "json"。否则,"json"将成为回调函数。

$.getJSON(url, function(data)
{
    console.log(data);
});

而不是getJSON你可以使用

$.get(url, function(data)
{
    console.log(data);
}, "json");