patched up to work with new gateway layout
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Nov 2005 20:52:21 +0000 (20:52 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Nov 2005 20:52:21 +0000 (20:52 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2138 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/common/js/RemoteRequest.js

index 6bfe179..8013d7d 100644 (file)
@@ -191,29 +191,33 @@ RemoteRequest.prototype.isReady = function() {
 
 /* returns the JSON->js result object  */
 RemoteRequest.prototype.getResultObject = function() {
+
        if(this.cancelled) return null;
        if(!this.xmlhttp) return null;
 
        var text = this.xmlhttp.responseText;
+       if(text == "" || text == " " || text == null) null;
+
        var obj = JSON2js(text);
 
-       if(obj == null) return null;
-       if(obj.is_err)  throw new EXCommunication(obj.err_msg); 
-       if( obj[0] != null && obj[1] == null ) obj = obj[0];
 
-       /* these are user level exceptions from the server code */
-       if(obj._isfieldmapper && obj.classname == "ex") {
-               if(!isXUL()) alert(obj.err_msg());
-               throw obj;
+       if( obj.status != 200 ) {
+               if(!isXUL()) {
+                       alert("A Server Error Occured.  Debug information follows:\n",
+                               "Status: " + obj.status + '\n' + obj.debug + '\n' 
+                               + 'Payload: ' + js2JSON(obj.payload) + '\n');
+               } else { throw obj; }
        }
 
-       if(obj.__isfieldmapper && obj.classname == "perm_ex") {
-               /* the opac will go ahead and spit out the error msg */
-               if(!isXUL()) alert(obj.err_msg());
-               throw obj;
+       var payload = obj.payload;
+       payload = (payload.length == 1) ? payload[0] : payload;
+
+       if(payload.__isfieldmapper && payload.classname == "perm_ex") {
+               if(!isXUL()) alert(payload.err_msg());
+               throw payload;
        }
 
-       return obj;
+       return payload;
 }
 
 /* adds a new parameter to the request */