From: Adam Dickmeiss Date: Tue, 7 Jan 2014 12:47:46 +0000 (+0100) Subject: Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/pazpar2 X-Git-Tag: v1.6.38~3 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=5ff4a545337696359ee78f70c6612484af8bc3bf;hp=a664c8403c99be624b3e169c51b75daab1145333;p=pazpar2-moved-to-github.git Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/pazpar2 --- diff --git a/js/pz2.js b/js/pz2.js index a0afe3a..8ae1379 100644 --- a/js/pz2.js +++ b/js/pz2.js @@ -775,17 +775,19 @@ var pzHttpRequest = function (url, errorHandler, cookieDomain) { this.errorHandler = errorHandler || null; this.async = true; this.requestHeaders = {}; - this.isXDomain = false; + this.isXDR = false; 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. - } 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(); - this.isXDomain = true; + this.isXDR = true; } else { // CORS not supported. } @@ -914,12 +916,12 @@ pzHttpRequest.prototype = } } this.request.open( type, url, this.async ); - if (!this.isXDomain) { + if (!this.isXDR) { //setting headers is only allowed with XHR for (var key in this.requestHeaders) this.request.setRequestHeader(key, this.requestHeaders[key]); } - if (this.isXDomain) { + if (this.isXDR) { this.request.onload = function () { //fake XHR props context.request.status = 200; @@ -956,7 +958,7 @@ pzHttpRequest.prototype = // pick up appplication errors first var errNode = null; // xdomainreq does not have responseXML - if (this.isXDomain) { + if (this.isXDR) { if (this.request.contentType.match(/\/xml/)){ var dom = new ActiveXObject('Microsoft.XMLDOM'); dom.async = false;