Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 11 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
以下是有效示例:
请注意请求 URL 末尾的
?callback=?
。这向getJSON
函数表明我们要使用 JSONP。删除它,将使用普通 JSON 请求。由于同源政策,这将失败。您可以在 JQuery 站点上找到更多信息和示例:http://api.jquery.com/jQuery。获取JSON/
Here is working example:
Notice the
?callback=?
at the end of the requested URL. That indicates to thegetJSON
function that we want to use JSONP. Remove it and a vanilla JSON request will be used. Which will fail due to the same origin policy.You can find more information and examples on the JQuery site: http://api.jquery.com/jQuery.getJSON/