Answer the question
In order to leave comments, you need to log in
How to send a cross domain request in IE8?
Hello!
It is necessary to send a cross-domain request from different browsers. It works in Firefox and Chrome, it works in IE11, but it doesn't work in IE8.
Code example:
if(window.XMLHttpRequest){
xhr = new XMLHttpRequest();
}
else if(window.ActiveXObject){
try{
xhr = new ActiveXObject('Msxl2.XMLHTTP');
} catch (e){}
try{
xhr = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e){}
}
if(xhr){
xhr.open("POST", 'http://mysite.ru', true);//отказано в доступе
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
xhr.onreadystatechange = function() {};
xhr.withCredentials = true;
xhr.send(json);
}
Answer the question
In order to leave comments, you need to log in
First, check if the web server of the destination site is returning the header .
More details can be found here .
Secondly, if the request is not on https, then IE8 will issue a warning window.
If you select "No" in it, then the choice is remembered for the duration of the session, and there will be an access error.
IE9 uses XDomainRequest, which is a stripped-down XMLHttpRequest.
It is subject to restrictions:
Подробнее можно почитать здесь
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question