*
* @license LGPL
* @author Dmitry Koterov, http://en.dklab.ru/lib/JsHttpRequest/
- * @version 5.x $Id$
+ * @version 5.x
*/
// {{{
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";
}
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);
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()) {
} 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)