Last active
May 15, 2018 16:11
-
-
Save limitedeternity/e96916c54aa656a80df564897ce51d90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addXMLRequestCallback(callback) { | |
var oldSend, i; | |
if (XMLHttpRequest.callbacks) { | |
XMLHttpRequest.callbacks.push(callback); | |
} else { | |
XMLHttpRequest.callbacks = [callback]; | |
oldSend = XMLHttpRequest.prototype.send; | |
XMLHttpRequest.prototype.send = function () { | |
for (i = 0; i < XMLHttpRequest.callbacks.length; i++) { | |
XMLHttpRequest.callbacks[i](this); | |
} | |
oldSend.apply(this, arguments); | |
} | |
} | |
} | |
addXMLRequestCallback(function(xhr) { | |
if (xhr.__state) { | |
console.dir(xhr.__state); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment