Skip to content

Instantly share code, notes, and snippets.

@scottshane
Last active January 26, 2017 03:51
Show Gist options
  • Save scottshane/0a7c6030a434fdb4d8cbb13cc84e30dc to your computer and use it in GitHub Desktop.
Save scottshane/0a7c6030a434fdb4d8cbb13cc84e30dc to your computer and use it in GitHub Desktop.
tiny xhr constructor
const xhr = new window['XMLHttpRequest' || 'ActiveXObject']('MSXML2.XMLHTTP.3.0');
let res;
xhr.open('GET', 'some/api/endpoint');
xhr.responseType = 'json';
xhr.onreadystatechange = function () {
if (this.status === 200 && this.readyState === 4) {
resp = this.response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment