I am facing this problem when using Xmlhttprequest to call ajax. I test the code on Firefox, Chrome, Safari, they all work well. Only problem existing in IE, my version used is 9. Some guys say that I should enable cross-domain support. In fact, I am adding Access-Control-Allow-Origin: * to the HTTP response header. Any ideas? Thank.
My code is:
var xhr = new XMLHttpRequest();
var query = queryString.pageName.abbr + "="
+ encodeURIComponent(queryString.pageName.value) + "&"
+ queryString.pageURL.abbr + "="
+ encodeURIComponent(queryString.pageURL.value);
var getURL = "http://localhost:10001/test?" + query;
xhr.open('GET', getURL, false);
var result;
xhr.onreadystatechange = function() {
var responseBody;
if (xhr.readyState == 2) {
alert(xhr.status);
} else if (xhr.readyState == 4) {
result = xhr.responseText;
}
};
xhr.send(null);
source
share