favor XHR in all other circumstances
this.errorHandler = errorHandler || null;
this.async = true;
this.requestHeaders = {};
this.errorHandler = errorHandler || null;
this.async = true;
this.requestHeaders = {};
- this.isXDomain = false;
this.domainRegex = /https?:\/\/([^:/]+).*/;
this.cookieDomain = cookieDomain || null;
var xhr = new XMLHttpRequest();
this.domainRegex = /https?:\/\/([^:/]+).*/;
this.cookieDomain = cookieDomain || null;
var xhr = new XMLHttpRequest();
+ var domain = this._getDomainFromUrl(url);
if ("withCredentials" in xhr) {
// XHR for Chrome/Firefox/Opera/Safari.
if ("withCredentials" in xhr) {
// XHR for Chrome/Firefox/Opera/Safari.
- } else if (typeof XDomainRequest != "undefined") {
- // XDomainRequest for IE.
+ } else if (domain && this._isCrossDomain(domain) &&
+ typeof XDomainRequest != "undefined") {
+ // use XDR (IE7/8) when no other way
xhr = new XDomainRequest();
xhr = new XDomainRequest();
} else {
// CORS not supported.
}
} else {
// CORS not supported.
}
}
}
this.request.open( type, url, this.async );
}
}
this.request.open( type, url, this.async );
//setting headers is only allowed with XHR
for (var key in this.requestHeaders)
this.request.setRequestHeader(key, this.requestHeaders[key]);
}
//setting headers is only allowed with XHR
for (var key in this.requestHeaders)
this.request.setRequestHeader(key, this.requestHeaders[key]);
}
this.request.onload = function () {
//fake XHR props
context.request.status = 200;
this.request.onload = function () {
//fake XHR props
context.request.status = 200;
// pick up appplication errors first
var errNode = null;
// xdomainreq does not have responseXML
// pick up appplication errors first
var errNode = null;
// xdomainreq does not have responseXML
if (this.request.contentType.match(/\/xml/)){
var dom = new ActiveXObject('Microsoft.XMLDOM');
dom.async = false;
if (this.request.contentType.match(/\/xml/)){
var dom = new ActiveXObject('Microsoft.XMLDOM');
dom.async = false;