Skip to content

Instantly share code, notes, and snippets.

@badrshs
Last active September 1, 2019 12:39
Show Gist options
  • Save badrshs/6eecc79802f7c0afd791c5668bac685f to your computer and use it in GitHub Desktop.
Save badrshs/6eecc79802f7c0afd791c5668bac685f to your computer and use it in GitHub Desktop.
read response from xhr requests
(function (open) {
XMLHttpRequest.prototype.open = function (method, url, async, user, pass) {
if(url=="some url ") { // remove this if you want to listen to everyhting
console.log(this.onreadystatechange);
this.addEventListener("readystatechange", function () {
console.log('readystate: ' + this.readyState);
if(this.responseText !== '') {
this.responseText = this.responseText.split('&')[0];
}
}, false);
}
open.call(this, method, url, async, user, pass);
};
})(XMLHttpRequest.prototype.open);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment