what is AJAX?
AJAX (asynchronous JavaScript and XML) is a newly generated term to describe the two powerful performance of JavaScript. This two item
can be overlooked by network developers over the years until recently Gmail
Maps />
people begin to realize the importance of.
these are ignored performance:
* can send a request.
* to the server to send a.
* to the server to parse and handle XML documents without reloading the whole page. A HTTP requests
to send a HTTP request to the server in order to JavaScript a class instance with this function. The class
this class is first introduced by Internet Explorer with ActiveX objects, called XMLHTTP. afterwards, and the other browsers are replicated in succession. The LHttpRequest class, which supports the methods and properties provided by the Microsoft ActiveX object,.
, so, in order to create a cross browser like class instance (object), you can apply the following code:
if (window.XMLHttpRequest) {/ / Mozilla, Safari,
= > > > / > > / > > / > > / > > / > > > / > > > / >
) else if (window.ActiveXObject) {/ / / IE
http_request = new ActiveXObject (.Quot; Microsoft.XMLHTTP.quot;) / > (the case is simplified to explain how to create an instance of the class. If the server's response does not have a XML mime-type header, some Mozilla browsers may not work properly. In order to solve this
problem, if the server response header is not text/xml, other methods can be called to modify the header.
http_request = new new (); RideMimeType ('text/xml');
what needs to be done following the response of the server. This needs to tell the HTTP request object to use which JavaScript function
to handle this response. You can set the onreadystatechange attribute of the object to the function name of the JavaScript to be used, as shown in the
note: there is no parenthesis after the function name, and there is no need to pass the parameters. In addition, there is a method to define the function and its response to the
response in the title page (fly), as shown in the following:
http_request.onreadystatechange = function ( ) {
/ / / / / / do the thing
>;
after defining how to deal with the response, the request is sent. The open () and send () method of the HTTP request class can be called. The first parameter of / > * open () is the mode of HTTP request - GET, POST, HEAD, or the way you want to call
. According to HTTP specification, the parameter should be uppercase; otherwise, some browsers (such as Firefox) may not be able to process the request. The detailed
fine information about the method for HTTP please refer to the detailed
details of the method. The second parameter of the 3.org/Protocols/rfc2616/rfc2616-sec9.html W3C specs
* is that the URL. of the request page is not a page of the third party domain name due to its own security characteristics. At the same time, a certain
ensures that the exact domain name is used in all the pages, otherwise the call open () will get.Quot; permissi. On denied.quot; an error hint. A
common error is to use domain.tld when accessing a site, and when the request page is requested, the request is asynchronous mode using the third parameters of www.domain.tld.
*. If TRUE, the JavaScript function will continue without waiting for the server to respond to
this. It is.Quot; AJAX.quot; in.Quot; A.quot;.
if the first parameter is.Quot; POST.quot; send () method, the parameter can be any data to the server. The data is sent to the server in the form of a string