In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today I'll tell you what the status of ajax requests are. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.
The status of the ajax request: 1, "uninitialized", indicating that the send () method has not been called; 2, "loading", indicating that the send () method has been called and sending the request; 3, "loading completed"; 4, "interaction", indicating that the response content is being parsed; 5, "complete", indicating that the response content parsing is complete and can be called on the client side.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Native ajax request is written:
Var http = new XMLHttpRequest (); http.open ('get','./package.json'); http.onreadystatechange = function () {if (http.readyState = = 4 & & http.status = = 200) {var result = JSON.parse (http.responseText); console.log (result.name)}}; http.send ()
5 states of ajax request (readyState)
0-(uninitialized) the send () method has not been called yet
1-(load) has called the send () method and is sending the request
2-(load completed) the send () method has been executed and all the response contents have been received.
3-(interactive) parsing response content
4-(complete) the parsing of the response content is complete and can be called on the client side.
ReadyState status description
(0) uninitialized
This phase confirms that the XMLHttpRequest object is created and does not call the open () method to prepare for uninitialization. A value of less than 0 indicates that the object already exists, otherwise the browser will report an error-the object does not exist.
(1) load
In this stage, the xml (standardization is getting closer and closer) HttpRequest object is initialized, that is, the open () method is called, and the object state is set according to the parameter (method,url,true). And call the send () method to start sending the request to the server. A value of 1 indicates that a request is being sent to the server.
(2) loading completed
This phase receives the response data from the server. However, what is obtained is only the original data of the server response, which can not be used directly on the client side. A value of 2 indicates that all response data has been received. And prepare for the next stage of data parsing.
(3) interaction
This phase parses the received server-side response data. That is, according to the MIME type returned by the server-side response header, the data is converted into a format that can be accessed through responseBody, responseText, or responsexml (standardization is getting closer and closer) attributes, in preparation for client-side call. Status 3 indicates that the data is being parsed.
(4) complete
This phase confirms that all the data has been parsed to the format available to the client, and the parsing is complete. A value of 4 means that the data has been parsed and can be obtained through the corresponding properties of the xml (standardization is getting closer and closer) HttpRequest object.
What is ajaxajax is a technology that can update part of the web page without reloading the whole web page. It can update the web page asynchronously by exchanging a small amount of data with the server in the background.
These are all the contents of the status of the ajax request, and more related to the status of the ajax request. You can search the previous articles or browse the following articles to learn! I believe the editor will add more knowledge to you. I hope you can support it!
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: 0
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.