Skip to content

Instantly share code, notes, and snippets.

@Jagathishrex
Created October 11, 2020 07:48
Show Gist options
  • Save Jagathishrex/950a51b41de626d9858c9e884ec68e3c to your computer and use it in GitHub Desktop.
Save Jagathishrex/950a51b41de626d9858c9e884ec68e3c to your computer and use it in GitHub Desktop.
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