Skip to content

Instantly share code, notes, and snippets.

@pingyen
Created November 8, 2016 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingyen/a21417bbb26c72756d78f1f49af7f754 to your computer and use it in GitHub Desktop.
Save pingyen/a21417bbb26c72756d78f1f49af7f754 to your computer and use it in GitHub Desktop.
Spy of XMLHttpRequest
(function() {
var prototype = XMLHttpRequest.prototype,
open = prototype.open,
send = prototype.send;
prototype.open = function() {
alert('open: ' + JSON.stringify(arguments));
open.apply(this, arguments);
};
prototype.send = function() {
alert('send: ' + JSON.stringify(arguments));
this.addEventListener('load', function() {
alert('load: ' + JSON.stringify(arguments));
});
send.apply(this, arguments);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment