【发布时间】:2012-10-19 07:07:27
【问题描述】:
我一直在 IE 9 中运行此代码,但运气不佳。我查看了所有关于 UTF-8 修复等的帖子,但无济于事。有什么想法吗?
$.get({
url: 'http://api.flickr.com/services/rest/?api_key={apikey}&method=flickr.collections.getTree&user_id=66970820%40N03&collection_id=66947766-72157631850748939',
success: function () {
console.log('success!');
}
}).done(function () {
console.log('done');
}).fail(function () {
console.log('fail')
});
它在 Safari、FF 和 Chrome 中运行良好。将URL粘贴到IE中时,响应很好。
【问题讨论】:
-
它到底是怎么不工作的?
-
在不了解全部情况的情况下,我会说您可能会遇到跨域问题。尝试查看 $.getJSON。特别是关于 JSONP 的部分。
-
URL 是无法跨域检索的 xml 文档...您需要将 jsonp dataType 添加到 $.get 并在 url 中为 jsonp 设置参数,以便 API 返回 jsonp 而不是 xml
-
IE8-9 不支持使用标准 ajax 方法的 CORS,这很可能是问题所在。
标签: jquery ajax internet-explorer