xmlhttprequest javascript 1

xmlhttprequest javascript

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
       // Typical action to be performed when the document is ready:
       document.getElementById("demo").innerHTML = xhttp.responseText;
xhttp.open("GET", "filename", true);

Here is what the above code is Doing:
1. Create a new XMLHttpRequest object.
2. Define what should happen when the server response is ready.
3. Send the request off to a file on the server.
4. Notice that the call to the function is wrapped in a try/catch block.

Similar Posts