(function (send) {
XMLHttpRequest.prototype.send = function () {
this.addEventListener('readystatechange', function() {
console.log('readyState changed');
}, false);
send.apply(this, arguments);
};
})(XMLHttpRequest.prototype.send);
This works, but it seems to be affecting other frameworks (like jQuery). When I use the code above, my jQuery ajax calls doen't complete (IE7 + IE8).
Is there any way to give the event a new alias so that it doesn't cause any conflicts (I'm just assuming that this is the problem)?
And I can't use this.onreadystatechange
, since jQuery is overwriting it (see Fiddle).
As soon as I bind the event listener, the code seems to fail silently so I can't use the console to debug.
Fiddle
Compare in ie8 vs ie9 mode and notice that the console is empty in ie8
The reason why I need this is that I want a global ajax handler for another framework (GWT). I use jQuery just for testing it now.
Edit: Looks like only ie9 supports addEventListener
. However, attachEvent
doesn't seem to exist on the XHR object in ie7-8.
We have had similar issue with jquery failing on IE8. I assume that you are making a cross domain request. Jquery does ajax through the XMLHttpRequest , but IE8 has replaced XMLHttpRequest object with XDomainRequest and jquery folks do not support it.So for IE8 , you will have to modify the code to use XDomainRequest with jquery.
see the links
Using jquery ajax for IE8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With