top of page

4/40 - Explore XML HttpRequest Object

The XMLHttpRequest provides developers with an option to send requests to the server after the webpage has been loaded. This provides a faster run time, but remember XML is not doing anything, it is the incorporation of Asynchronous JavaScript And XML (AJAX) that increases speed when communicating with the server. We will explore the standard building process of AJAX in a later post.


Today we will explore the common JavaScript syntax when using the XMLHttpRequest. With the following lines of code any

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
       document.getElementById("demo").innerHTML = xhttp.responseText; }};
xhttp.open("GET", "filename", true);
xhttp.send();

 
 
 

Comments


bottom of page