Created
September 25, 2020 08:50
-
-
Save Theo-denBlanken/5341b5da0c2d193bfc232bc563a2ae35 to your computer and use it in GitHub Desktop.
HTTPRequest in JavaScript asynchroon JS
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 xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = () => { | |
if(xhr.readyState == 4 && xhr.status ==200) { | |
let resultaat = JSON.parse(xhr.responseText); | |
console.log(resultaat); | |
} | |
} | |
xhr.open('GET', 'boeken.json', true); | |
xhr.send(); | |
console.log('Het script heeft deze regel uitgevoerd. Dit zal eerder gebeuren dan regel 6!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment