Created
October 11, 2020 07:48
-
-
Save Jagathishrex/950a51b41de626d9858c9e884ec68e3c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let url = "https://medium.com/search?q=javascriptjeep"; | |
let request = new XMLHttpRequest(); | |
console.log(request.readyState); // 0 | |
//after calling open the state will be changed to 1 | |
request.open("GET", url); | |
console.log(request.readyState); // 1 | |
// we need to implement readystatechange event to detect 2,3,4, events | |
request.onreadystatechange = function() { | |
console.log(request.readyState) | |
if (request.readyState == 2) { | |
console.log("Header received"); | |
} else if (request.readyState == 3) { | |
console.log("loading"); | |
} else if (request.readyState == 4) { | |
console.log("Request Finished"); | |
} | |
}; | |
request.send() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment