Created
October 22, 2020 10:09
-
-
Save DesireeBesnard/5631b5ec386793acbe2c4bf05f491a05 to your computer and use it in GitHub Desktop.
AJAX Request with XHR object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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