X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=js%2Fpz2.js;h=bf6a9b8235a2e7432a00b5227494c0325995284f;hb=e9b634358fec25ebdeeee0461705469d01c82c77;hp=800546e39f7cc3b5c397d9c64a2be4e04df2017c;hpb=b8fe4f668ee8f33ff8629e090dbcdf2860060a1b;p=pazpar2-moved-to-github.git diff --git a/js/pz2.js b/js/pz2.js index 800546e..bf6a9b8 100644 --- a/js/pz2.js +++ b/js/pz2.js @@ -1,5 +1,4 @@ /* -** $Id: pz2.js,v 1.70 2008-03-12 11:36:57 jakub Exp $ ** pz2.js - pazpar2's javascript client library. */ @@ -751,7 +750,7 @@ pzHttpRequest.prototype = for (var key in this.requestHeaders) this.request.setRequestHeader(key, this.requestHeaders[key]); this.request.onreadystatechange = function () { - context._handleResponse(); + context._handleResponse(url); /// url used ONLY for error reporting } this.request.send(data); }, @@ -764,7 +763,7 @@ pzHttpRequest.prototype = return this.url; }, - _handleResponse: function () + _handleResponse: function (savedUrlForErrorReporting) { if ( this.request.readyState == 4 ) { // pick up appplication errors first @@ -787,6 +786,16 @@ pzHttpRequest.prototype = else { throw err; } + } else if (this.request.status == 200 && + this.request.responseXML == null) { + var err = new Error("XML response is empty but no error " + + "for " + savedUrlForErrorReporting); + err.code = -1; + if (this.errorHandler) { + this.errorHandler(err); + } else { + throw err; + } } else if (this.request.status == 200) { this.callback(this.request.responseXML); } else {