English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Pure JS implementation of AJAX partial refresh function

AJAX, which stands for “Asynchronous Javascript And XML”, refers to a web development technology for creating interactive web applications.

AJAX = Asynchronous JavaScript and XML (a subset of the Standard Generalized Markup Language).

AJAX is a technology used to create fast dynamic web pages.

The following introduces the JS implementation of AJAX partial refresh function, as shown below:

AJAX can enable web pages to implement asynchronous updates by exchanging a small amount of data in the background with the server. This means that part of the web page can be updated without reloading the entire web page.

// Create XMLHttpRequest object
 var xhr=new XMLHttpRequest();
 // Request line
 xhr.open('post','03-ajaxPost.php');
 //Request headers
 xhr.setRequestHeader('Content-Type',' application/x-www-form-urlencoded');
 //Request body post send sets data
 xhr.send('name='+txt);
 //Listen to the server's response
 xhr.onreadystatechange=function(){
 if(xhr.readyState==4&&xhr.status==200){ //This indicates that the server's response is accepted successfully
 var r=xhr.responseText;
 document.querySelector('.info').innerHTML=r;
 }
 } 

The above is the pure JS implementation of AJAX partial refresh function introduced by the editor for everyone, hoping it will be helpful to everyone. If anyone has any questions, please leave a message, and the editor will reply in time. Here, the editor also expresses sincere gratitude to everyone for their support of the Yanaolang tutorial website!

You May Also Like