const xhttp = new XMLHttpRequest()
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
const data = JSON.parse(this.responseText)
// handle the response that is saved in variable data
}
}
xhttp.open('GET', '/data.json', true)
xhttp.send()
Thursday, October 21, 2021
How to fetch data from server using XHR method
Subscribe to:
Post Comments (Atom)
JavaScript Functions as JavaScript Variables
In Javascript instead of declaring and executing a function in two different steps. for example step 1 - function add(a,b){return a+b;} ste...
-
function Dog ( name ) { this . name = name ; } Dog . prototype . numLegs = 4 ; let beagle = new Dog ( "Snoopy" );...
-
In Javascript instead of declaring and executing a function in two different steps. for example step 1 - function add(a,b){return a+b;} ste...
-
Middleware are functions that can be used for handling request and response objects. In practice, you can use several middlewares at t...
No comments:
Post a Comment