带CORS的IE9 jQuery AJAX返回“访问被拒绝”以下适用于IE以外的所有浏览器(我在IE 9中测试)。jQuery.support.cors = true;...
$.ajax(
url + "messages/postMessageReadByPersonEmail",
{
crossDomain: true,
data: {
messageId : messageId,
personEmail : personEmail
},
success: function() {
alert('marked as read');
},
error: function(a,b,c) {
alert('failed');
},
type: 'post'
}
);我有另一个使用的函数dataType: 'jsonp',但我不需要在这个AJAX调用上返回任何数据。我的最后一招将是返回JSONP中包含的一些乱码,以使其正常工作。任何想法为什么IE搞砸了没有返回数据的CORS请求?
3 回答
郎朗坤
TA贡献1921条经验 获得超9个赞
我使用MoonScript的jQuery.XDomainRequest.js 成功完成了这个。
以下代码在Chrome,Firefox和IE10中正常运行,但在IE9中失败。我只是包含了脚本,它现在可以在IE9中自动运行。(可能是8,但我还没有测试过。)
var displayTweets = function () {
$.ajax({
cache: false,
type: 'GET',
crossDomain: true,
url: Site.config().apiRoot + '/Api/GetTwitterFeed',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (data) {
for (var tweet in data) {
displayTweet(data[tweet]);
}
}
});};- 3 回答
- 0 关注
- 1234 浏览
添加回答
举报
0/150
提交
取消
