From 689dae353fd3c852193c2851b250061cf6b0e6dd Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 30 Nov 2005 20:52:21 +0000 Subject: [PATCH] patched up to work with new gateway layout git-svn-id: svn://svn.open-ils.org/ILS/trunk@2138 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/common/js/RemoteRequest.js | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Open-ILS/web/opac/common/js/RemoteRequest.js b/Open-ILS/web/opac/common/js/RemoteRequest.js index 6bfe179fd3..8013d7d7b8 100644 --- a/Open-ILS/web/opac/common/js/RemoteRequest.js +++ b/Open-ILS/web/opac/common/js/RemoteRequest.js @@ -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 */ -- 2.43.2