In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what are the advantages and disadvantages of Ajax technology". 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 "what are the advantages and disadvantages of Ajax technology"?
Ajax:Asynchronous Javascript and XML asynchronous Javascript and XML.
It is a web page development technology for creating interactive web page applications.
1.0 benefits:
1.1 enhanced user experience through asynchronous mode.
1.2 optimizes the transmission between the browser and the server, reduces unnecessary data round trips and reduces bandwidth consumption.
1.3 the Ajax engine runs on the client side and undertakes part of the common group originally undertaken by the server, thus reducing the server load under a large number of users.
2.0 how it works
The core of Ajax is the Javascript object XmlHttpRequest. This object, which is first referenced in IE5, is a technology that supports asynchronous requests. XmlHttpRequest allows you to use Javascript to make requests to the server and process responses, rather than blocking users, with no refresh.
Due to differences between browsers, there are also differences in the way XmlHttpRequest objects are created (mainly because of the differences between IE and other browsers).
2.1 compare general methods for creating asynchronous requests:
The copy code is as follows:
Function CreateXmlHttp () {
/ / methods of creating XmlHttpRequest objects in non-IE browsers
If (window.XmlHttpRequest) {
Xmlhttp = new XmlHttpRequest ()
}
/ / the method of creating XmlHttpRequest object by IE browser
If (window.ActiveXObject) {
Try {
Xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP")
}
Catch (e) {
Try {
Xmlhttp = new ActiveXObject ("msxml2.XMLHTTP")
}
Catch (ex)
{}
}
}
}
2.2 XmlHttpRequest related attributes:
Onreadystatechange event handler for the event triggered by each state change.
ResponseText returns data from the server process in a string form.
The DOM-compatible document data object returned by responseXML from the server process.
Status returns numeric codes from the server, such as the common 404 (not found) and 200 (ready)
String information of status Text accompanying status code
ReadyState object status value
0 (uninitialized) object has been established, but has not been initialized (open method has not been called)
1 (initialization) object has been established and the send method has not been called
2 (send data) the send method has been called, but the current state and http header are unknown
3 (data transfer) has received part of the data, because the response and http headers are incomplete, there will be an error in obtaining part of the data through responseBody and responseText
4 (complete) the data has been received, and the complete response data can be obtained through responseXml and responseText
2.3 simple example of Demo:
The copy code is as follows:
Function SendAsyncRequest () {
Var data = document.getElementById ("XXId") .value
CreateXmlHttp (); / / create a XmlHttpRequest object
If (! xmlhttp) {/ / determine whether the object is created successfully
Alert ("create xmlhttp object exception!")
Return false
}
Xmlhttp.open ("POST", url, false); / / start sending asynchronous requests
Xmlhttp.onreadystatechange = function () {
If (xmlhttp.readyState = = 4 & & xmlhttp.status = = 200) {
Document.getElementById ("XXShowId") [xss_clean] = xmlhttp.ResponseText; / / data reception completed
}
}
Xmlhttp.send ()
}
3.0 disadvantages:
1. Destroy the normal behavior of the browser back button, after dynamically updating the page, can not return to the state of the previous page.
two。 Using Javascript as the basic engine of Ajax, Javascript compatibility is not very good.
Thank you for your reading, the above is the content of "what are the advantages and disadvantages of Ajax technology". After the study of this article, I believe you have a deeper understanding of the advantages and disadvantages of Ajax technology, 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: 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.