Everything seems to be in order:
(function() {
var open_original = XMLHttpRequest.prototype.open;
var send_original = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.open = function(method, url, async, unk1, unk2) {
open_original.apply(this, arguments);
};
XMLHttpRequest.prototype.send = function(data) {
this.onreadystatechange = function() {
console.log('Works for me.');
}
send_original.apply(this, arguments);
};
})();
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', '/echo/html/', true);
xmlhttp.send();
http://jsfiddle.net/ers2s80a/

Petah source
share