Hi,
I'm trying to get the following code to work. I'm intercepting all Ajax requests and responses by overriding XMLHttpRequest functions. The requests are alerted and sent correctly.
I also get an alert box for responses, but after that I get an error "this.orsc is not a function", and the response is not delivered correctly. Any idea what the problem is?
Code:
XMLHttpRequest.prototype.realSend = XMLHttpRequest.prototype.send;
var newSend = function(data) { alert("sent: " + data); if(this.onreadystatechange) { this.orsc = this.onreadystatechange; } this.onreadystatechange = newORSC; this.realSend(data); };
var newORSC = function() { if (this.readyState == 4) { alert("response: " + this.responseText); } this.orsc(); };
XMLHttpRequest.prototype.send = newSend;