mod_json_streams/strophe.jsonstreams.js: Fix some compatability issues.
--- a/mod_json_streams/strophe.jsonstreams.js Sat Apr 02 03:11:22 2011 +0500
+++ b/mod_json_streams/strophe.jsonstreams.js Sat Apr 02 04:27:43 2011 +0500
@@ -39,7 +39,8 @@
return _xhr.send(data);
}
};
- xhr.onreadystatechange = _xhr.onreadystatechange;
+ var req = this;
+ xhr.onreadystatechange = this.func.bind(null, this);
_xhr.onreadystatechange = function() {
xhr.readyState = _xhr.readyState;
if (xhr.readyState != 4) {
@@ -50,7 +51,9 @@
xhr.status = _xhr.status;
xhr.responseText = _xhr.responseText;
xhr.responseXML = _xhr.responseXML;
- if (_xhr.responseText && !_xhr.responseXML) {
+ if (_xhr.responseText && !(_xhr.responseXML
+ && _xhr.responseXML.documentElement
+ && _xhr.responseXML.documentElement.tagName != "parsererror")) {
var data = JSON.parse(_xhr.responseText);
if (data && data.s) {
xhr.responseText = data.s;
@@ -58,7 +61,7 @@
}
}
}
- if (xhr.onreadystatechange) { xhr.onreadystatechange(); }
+ if ("function" == typeof xhr.onreadystatechange) { xhr.onreadystatechange(req); }
}
return xhr;
};