AJAX - GET Method

by Devansh

Posted on 08 Mar 2018 09:03:30 (2 years ago)

Normally, we use GET method to get the data from the database. Now, we instantiate an object of 'XMLHttpRequest' to use the AJAX. Then we check the ready states and status as we talked about earlier. If you don't know about ready states and status please see the previous section. It's an important to check whether the response is ready or not. Below is the full code,

var theObject = new XMLHttpRequest();
theObject.open("GET", "example.php", true);
theObject.onreadystatechange = function() {
     if (theObject.readyState == 4 && theObject.status == 200) {