Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

ajax

var xhr = new XMLHttpRequest;
var url = "/?lorem=ipsum";

//GET request
xhr.open('GET', url); //Open the request with the specified url.
xhr.onreadystatechange = () => {
  //Checking if the request has finished and if it was successfull  
  if (xhr.readyState == 4 && xhr.status == 200) {
        console.log(xhr.responseText); //Printing out the response. 
    	//You can also use xhr.responseXML
    }
}
xhr.send(); //This sends the request to the server with the specified params.
Source by api.jquery.com #
 
PREVIOUS NEXT
Tagged: #ajax
ADD COMMENT
Topic
Name
8+3 =