In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to understand AJAX development technology". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
AJAX (Asynchronous JavaScript and XML, Asynchronous JavaScript and XML), AJAX is not a new technology, its main purpose is for local page refresh. From the previous code development, readers can find that whenever a user makes a request to the server, even if only a little bit of local content is simply updated, the server will refresh the whole page and regenerate the code. In this way, the performance of the program will certainly be reduced, and if you use AJAX technology, you can achieve local content changes, without the overall page refresh, obviously the performance of processing is much higher than the former.
In AJAX, asynchronous requests and responses are mainly handled through the XMLHttpRequest object, which first appeared as an ActiveX component in IE 5 and was not widely used until 2005, and JavaScript must be used if you want to create a XMLHttpRequest object.
Properties of the XMLHttpRequest object
No.
Attribute
Description
one
Onreadystatechange
Specifies the action to be used when the readState state changes, which is generally used to specify a specific callback function
two
ReadyState
Returns the status of the current request, read-only
three
ResponseBody
Returns the body of the response message as a unsigned byte array, read-only
four
ResponseStream
Returns response information as an Ado Stream object, read-only
five
ResponseText
Receive data returned in plain text, read-only
six
ResponseXML
Receive data in the form of an XML document, read-only
seven
Status
Returns the http status code of the current request, read-only
eight
StatusText
Returns the response line status of the current request, read-only
Create a XMLHttpRequest object
The copy code is as follows:
Var xmlHttp; / / AJAX core object name
Function createXMLHttp () {/ / create XMLHttpRequest core object
If (window.XMLHttpRequest) {/ / determine the type of browser currently in use
XmlHttp = new XMLHttpRequest (); / / indicates that the browser used is the FireFox kernel
} else {/ / indicates that you are using a browser with IE kernel
XmlHttp = new ActiveXObject ("Microsoft.XMLHTTP")
}
}
There are five values for readState-one, which are:
The request is not made (before calling the open () function).
The request has been made but has not been issued (before calling the send () function).
The request has been made and is being processed (here you can usually get the content header from the response).
The request has been processed and information from the server is being received. Some data is usually available in the response, but the server has not yet completed the response.
The response is complete, and you can access the server response and use it.
Methods of XMLHttpRequest object
No.
Method
Description
one
Abort ()
Cancel the current request
two
GetAllResponseHeaders ()
Get all the HTTP header information
three
GetResponseHeader ()
Get a specified HTTP header information
four
Open ()
Create a HTTP request and specify the request mode, for example: GET request or POST request
five
Send ()
Send the created request to the server and receive the response message
six
SetRequestHeader ()
Sets the HTTP header information for a specified request
AJAX encapsulated code
Ajax.js
The copy code is as follows:
Function Ajax (recvType) {
Var aj=new Object ()
Aj.recvType=recvType? RecvType.toUpperCase (): 'HTML' / / HTML XML
Aj.targetUrl=''
Aj.sendString=''
Aj.resultHandle=null
Aj.createXMLHttpRequest=function () {
Var request=false
/ / the presence of XMLHttpRequest in the window object is non-IE, including (IE7,IE8)
If (window.XMLHttpRequest) {
Request=new XMLHttpRequest ()
If (request.overrideMimeType) {
Request.overrideMimeType ("text/xml")
}
/ / if the ActiveXObject attribute exists in the window object, it is IE
} else if (window.ActiveXObject) {
Var versions= ['Microsoft.XMLHTTP',' MSXML.XMLHTTP', 'Msxml2.XMLHTTP.7.0','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.5.0',' Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0',' MSXML2.XMLHTTP']
For (var item0; I
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.