Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the process of the ajax interaction model

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 261

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report