I am doing a cross domain request using $.ajax. It works on Firefox and Chrome, but does not issue a call on IE 7 or 8. Can anyone tell me what’s wrong with the following?
- I have used JSON and JSONP (which I stopped using, due to some custom restrictions).
- I am already using
Allow-access-control-originheader on my site. (Without those, Chrome and Firefox were not making successful requests.) - I have already tried https://developer.mozilla.org/en/http_access_control
Code:
$.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);
}
});
I have tried various tips present on multiple sites, but no luck yet.
Could you check if the problem with IE relies on not defining security zones to allow cross domain requests? See this microsoft page for an explanation.
OTOH, this page mentions that IE7 and eariler cannot do cross domain calls, but IE8 can, using a different object than XMLHttpRequest, the one JQuery uses. Could you check if XDomainRequest works?
EDIT (2013-08-22)
The second link is dead, so I’m writing here some of its information, taken from the wayback machine: