From: Jakub Skoczen Date: Wed, 10 Sep 2008 08:17:39 +0000 (+0200) Subject: IE proof checks for response XML doc. X-Git-Tag: v1.1.0~113^2 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=624d4ff2e24967bafd51c52e1eba9b4cd64ee79d;p=pazpar2-moved-to-github.git IE proof checks for response XML doc. --- diff --git a/js/pz2.js b/js/pz2.js index 4e2702f..53c0c2a 100644 --- a/js/pz2.js +++ b/js/pz2.js @@ -777,25 +777,17 @@ pzHttpRequest.prototype = _handleResponse: function () { if ( this.request.readyState == 4 ) { - // pick up pazpr2 errors first - if ( this.request.responseXML - && this.request.responseXML.documentElement.nodeName == 'error' - && this.request.responseXML.getElementsByTagName("error") - .length ) { + // pick up appplication errors first + var errNode = null; + if (this.request.responseXML && + (errNode = this.request.responseXML.documentElement) + && errNode.nodeName == 'error') { + var errMsg = errNode.getAttribute("msg"); + var errCode = errNode.getAttribute("code"); var errAddInfo = ''; - if ( this.request.responseXML.getElementsByTagName("error")[0] - .childNodes.length ) - errAddInfo = ': ' + - this.request.responseXML - .getElementsByTagName("error")[0] - .childNodes[0].nodeValue; - var errMsg = - this.request.responseXML.getElementsByTagName("error")[0] - .getAttribute("msg"); - var errCode = - this.request.responseXML.getElementsByTagName("error")[0] - .getAttribute("code"); - + if (errNode.childNodes.length) + errAddInfo = ': ' + errNode.childNodes[0].nodeValue; + var err = new Error(errMsg + errAddInfo); err.code = errCode; @@ -805,13 +797,13 @@ pzHttpRequest.prototype = else { throw err; } - } else if ( this.request.status == 200 ) { - this.callback( this.request.responseXML ); + } else if (this.request.status == 200) { + this.callback(this.request.responseXML); } else { - var err = new Error("Pz2.js: HTTP request error (AJAX). Code: " - + this.request.status + " Info: " + var err = new Error("HTTP response not OK: " + + this.request.status + " - " + this.request.statusText ); - err.code = 'HTTP'; + err.code = '00' + this.request.status; if (this.errorHandler) { this.errorHandler(err);