In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.