What is the process of the ajax interaction model
This article mainly explains "how the process of the ajax interaction model is". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how the process of the ajax interaction model is.
The interaction model of ajax is: 1, users send asynchronous requests; 2, use onReadyStateChange to listen; 3, create requests, use open method to specify whether it is get or post, whether asynchronous, url address; 4, send requests; 5, accept results and analysis; 6, achieve refresh.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Ajax full name: Asychronous javascript and xml, is a kind of creation interactive web page application web page development technology.
The interaction Model of ajax
1. The user issues an asynchronous request
two。 Using onReadyStateChange snooping
3. To create a request, use the open method to specify whether it is get or post, whether it is asynchronous, and the url address.
4. Send request, send method
5. Accept the results and analyze
6. Implement refresh
Synchronous and asynchronous differences:
Synchronization: the script stays and waits for the server to send a reply before continuing
Asynchronous: the script allows the page to continue its process and handle possible replies
Var xhr = new XMLHttpRequest (); xhr.open ('request method GET or POST or other', request address url, whether asynchronous async is enabled); xhr.onreadystatechange = function () {/ / readyState = = 4 indicates that the request has been completed if (xhr.readyState = = 4 & & xhr.status = = 200) {console.log (xhr.responseText) }} if (method = = 'POST') {/ / assign xhr.setRequestHeader (' Content-type', 'application/x-www-form-urlencoded') to the specified HTTP request header } xhr.send () Thank you for your reading, the above is the content of "what is the process of ajax interaction model". After the study of this article, I believe you have a deeper understanding of the process of ajax interaction model, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!