尝试解析 JSONP 时 jQuery 和 $.ajax 出现问题
所以,这是我的 JSONP URL:
http://community.tradeking.com/leaderboard.js
这是我试图解析它的 jQuery:
$.ajax({
dataType: 'jsonp',
jsonp: 'callback',
url: 'http://community.tradeking.com/leaderboard.js?callback=?',
success: function () {
alert("something");
},
});
这是我在 Firebug 中遇到的错误:
processLeaderboard 未定义
我也尝试过 getJSON 和 jQuery JSONP 特定插件,但它们都以类似的方式失败。 JSONP 已在其他地方成功使用。
So, here's my JSONP URL:
http://community.tradeking.com/leaderboard.js
And here's the jQuery I'm trying to parse it with:
$.ajax({
dataType: 'jsonp',
jsonp: 'callback',
url: 'http://community.tradeking.com/leaderboard.js?callback=?',
success: function () {
alert("something");
},
});
And here's the error I'm getting in Firebug:
processLeaderboard is not defined
I've also tried getJSON and the jQuery JSONP specific plugin, but they all fail in similar ways. The JSONP is being used successfully elsewhere.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要一个名为
processLeaderboard
的函数,因为该函数名称似乎已硬编码到链接的响应中。You need a function that is called
processLeaderboard
, since that function name seems hardcoded into the response from your link.这对我来说在使用 chrome 的 jsbin 中工作得很好。
This worked just fine for me in jsbin using chrome.