In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 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 core technical codes of Ajax". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the core technical codes of Ajax"?
The copy code is as follows:
Var xhr =''
Function Ajax ()
{
If (window.XMLHttpRequest)
{
Var xhr = new XMLHttpRequest;// Modern browser
} else
{
Var xhr = new ActiveXObject ('Microsoft.XMLHTTP'); / / IE
}
}
Ajax (); / / 1. Get Ajax object
Xhr.onreadystatechange = function ()
{
If (xhr.readyState = = 4 & & xhr.status = = 200)
{
Var data = xhr.responseText;//2. Judge status, receive data (in string form), follow-up operation
}
}
/ / xhr.open ('request method', 'request address', TRUE); / / 3. Asynchronous transmission connection
/ / xhr.send ([data]); / / 4. Send a request
Xhr.open ('GET',' demo.php?name=weichen&sex=0', TRUE)
Xhr.send ()
/ *
Xhr.open ('POST',' demo.php', TRUE)
Xhr.setResponseHeader ('Content-Type',' application/x-www-form-urlencoded')
Xhr.send ('name=weichen&sex=0')
, /
Member properties and member methods in the XHR object
The copy code is as follows:
{
Member attributes:
The HTTP status code of the status server response (for example, 200or 404)
The HTTP status code (ok or not found) returned as a string for the statusText server response
Status code requested by the readyState browser (0 to 4)
The data result in string format of the responseText server response
Data results in XML format of the response from the responseXML server
Request event for onreadystatechange Ajax (event handler called when readystate changes)
Event handler function of Mozilla that is called when an error occurs during an onerror request
Event handling function of mozilla called after onprogress content is loaded
The event handling function of mozilla called after the onload document is loaded
Member method:
SetRequestHeader (); sets the header header information for the current request (adds a key / value pair to the header to be sent to the server)
Open (); establish a new request connection (initialize the XHR object with GET, POST, URL, etc.)
Send (); send a request (data that may need to be sent)
GetResponseHeader ("server"); returns the value of the specified HTTP header (such as server or last-modified)
GetAllResponseHeaser (); returns a string of all HTTP headers split by a newline character
Absort (); terminate the request
}
At this point, I believe you have a deeper understanding of "what are the core technical codes of Ajax?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.