我使用 JQuery ajax 跨域获取 Json 数据。我的代码可以在 Firefox 和 Chrome 下运行,但 IE 是个大麻烦。它在 IE 10 中工作,但不少于。我需要让它在更少的 IE8 或更高版本上运行,因为它们仍然是大多数。这是我的代码:
jQuery.support.cors = true;
$.ajax({
type: 'GET',
url: "https:xxx.com",
crossDomain: true,
cache: false,
dataType: "json",
headers : {
"Accept-Datetime" : "Tue, 12 Feb 2013 00:00:00 GMT",
"Authorization" : "Basic XXXXXXXX"
},
success: processDetailsViewData,
error: function(xhr, status, error){
console.log(xhr.responseText, status, error);
}
});
我尝试使用 jQuery.XDomainRequest.js,它只能在 http 或 https 之间工作。我不需要任何回调,我需要在请求中包含“Accept-Datetime”和“Authorization”。所以我想我不需要使用 JsonP。以前有人处理过这个案子吗?干杯。