我正在使用$.ajax
进行跨域请求。在Firefox和Chrome上可以工作,但在IE 7或8上不会发出调用。有人能告诉我以下代码有什么问题吗?
- 我已经尝试使用JSON和JSONP(由于一些自定义限制,我停止了使用JSONP)。
- 我已经在我的网站上使用了
Allow-access-control-origin
头部。(没有这些头部,Chrome和Firefox无法进行成功的请求。) - 我已经尝试过https://developer.mozilla.org/en/http_access_control
代码:
$.ajax({
type: 'GET',
url: "http://anotherdomain.com/Service/GetControl?id=" + zoneID,
cache: false,
contentType: "application/x-www-form-urlencoded",
async: false,
beforeSend: function (request) {
//alert('before send');
//request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
//request.setRequestHeader("X-PINGOTHER", "pingpong");
} ,
success: function (data, status) {
//alert("Data returned :" + data);
//alert("Status :" + status);
if (status == "success" && data != "")
$("#" + div.id).append(data);
else
$("#" + div.id).attr("style", "display:none;");
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown);
}
});
我尝试了多个网站上的各种提示,但仍然没有成功。