X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=js%2FJsHttpRequest.js;h=1a1a2ec92e9df55aca11f3110b2b942e05fd41ab;hb=6bcd87642330092910f5d6977845a76ac59350ac;hp=3ec48fd3328e35c2fc22bf4055d0e9adc9ea6a2a;hpb=f7d5b6bb6541df3591610e08bf83ccb8b107ea31;p=fa-stable.git diff --git a/js/JsHttpRequest.js b/js/JsHttpRequest.js index 3ec48fd3..1a1a2ec9 100644 --- a/js/JsHttpRequest.js +++ b/js/JsHttpRequest.js @@ -3,7 +3,7 @@ * * @license LGPL * @author Dmitry Koterov, http://en.dklab.ru/lib/JsHttpRequest/ - * @version 5.x $Id$ + * @version 5.x */ // {{{ @@ -192,6 +192,9 @@ function JsHttpRequest() { status = 200; statusText = "OK"; } else { + // The special value "null" from a backend means Fatal error. + // User cannot assign null to $_RESULT manually, it is + // translated to false to avoid 500 error collisions. status = 500; statusText = "Internal Server Error"; } @@ -255,7 +258,7 @@ function JsHttpRequest() { if (tn == 'FORM') { // FORM itself is passed. formAdded = true; - } else if (tn == 'INPUT' || tn == 'TEXTAREA' || tn == 'SELECT') { + } else if (tn == 'INPUT' || tn == 'TEXTAREA' || tn == 'SELECT' || tn == 'BUTTON') { // This is a single form elemenent. } else { return this._error('inv_form_el', (v.name||''), v.tagName); @@ -457,7 +460,7 @@ JsHttpRequest.LOADERS.xml = { loader: function(req) { if (this.queryElem.length) return ['xml_no_form_upl']; // XMLHttpRequest (and MS ActiveX'es) cannot work with different domains. - if (this.url.match(new RegExp('^([a-z]+://[^\\/]+)(.*)', 'i'))) { + if (this.url.match(new RegExp('^([a-z]+://[^\\/]+)(.*)((:[0-9]*)+)', 'i'))) { // We MUST also check if protocols matched: cannot send from HTTP // to HTTPS and vice versa. if (RegExp.$1.toLowerCase() != document.location.protocol + '//' + document.location.hostname.toLowerCase()) { @@ -507,8 +510,10 @@ JsHttpRequest.LOADERS.xml = { loader: function(req) { } catch (e) {} if (!req.status) return; try { + // Damned Opera returned empty responseText when Status is not 200. + var rtext = req.responseText || '{ js: null, text: null }'; // Prepare generator function & catch syntax errors on this stage. - eval('JsHttpRequest._tmp = function(id) { var d = ' + req.responseText + '; d.id = id; JsHttpRequest.dataReady(d); }'); + eval('JsHttpRequest._tmp = function(id) { var d = ' + rtext + '; d.id = id; JsHttpRequest.dataReady(d); }'); } catch (e) { // Note that FF 2.0 does not throw any error from onreadystatechange handler. return req._error('js_invalid', req.responseText)