【发布时间】:2011-11-13 12:24:20
【问题描述】:
我正在使用 jQuery (1.7.0) 对 Spotify 进行 json/ajax 调用。以下代码在 Chrome 和 Firefox 中运行良好,但在 IE 中会导致错误(错误:访问被拒绝。)。
$.ajax({
url: 'http://ws.spotify.com/lookup/1/.json',
type: 'GET',
dataType: 'json',
cache: true,
data: {
uri: "someartist",
extras: "album"
},
success: successfn,
error:function(xhr, status, errorThrown) {
alert("networking error: "+errorThrown+'\n'+status+'\n'+xhr.statusText);
}
});
在 Chrome 和 FF 中调用了成功函数,但在 IE 中调用了错误函数并显示上述消息。我已将 cors 设置为 true:jQuery.support.cors = true;。
它在本地和我的服务器上都可以在 Chrome 和 FF 上运行,它可以在本地 IE 中运行,但不能在服务器上运行。更改 cache: false 会导致 spotify 端出现问题 - 不会添加其他参数,因此我收到“错误请求”错误。
感谢任何指点。
谢谢
阿波
【问题讨论】:
标签: ajax internet-explorer jquery