Skip to content

Instantly share code, notes, and snippets.

@DesireeBesnard
Created October 22, 2020 10:09
Show Gist options
  • Save DesireeBesnard/5631b5ec386793acbe2c4bf05f491a05 to your computer and use it in GitHub Desktop.
Save DesireeBesnard/5631b5ec386793acbe2c4bf05f491a05 to your computer and use it in GitHub Desktop.
AJAX Request with XHR object
const request = new XMLHttpRequest();
function myFunction() {
request.onreadystatechange = function() {
if (this.readyState == XMLHttpRequest.DONE && this.status == 200) {
let response = JSON.parse(this.responseText);
console.log(response);
}
}
request.open('GET', 'https://www.mywebservice');
request.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment