Skip to content

Instantly share code, notes, and snippets.

@luisenriquecorona
Created June 4, 2019 21:23
Show Gist options
  • Save luisenriquecorona/4feb210ba8eb4d9d8e2a9f627fb0d428 to your computer and use it in GitHub Desktop.
Save luisenriquecorona/4feb210ba8eb4d9d8e2a9f627fb0d428 to your computer and use it in GitHub Desktop.
Intercepting network requests HTTPrequest using the XMLHTTPRequest object
var request;
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
request = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
request = new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {}
} }
request.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
doSomething(this.responseText);
}
};
// Open, send.
request.open('GET', '/some/url', true);
request.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment