Ajax is asynchronous JavaScript and XML, asynchronous JavaScript and XML, where the primary user interacts with the server data without refreshing the page.
The main object used by Ajax is XMLHttpRequest (ActiveXObject in IE5, IE6)
if (window. XMLHttpRequest) {
XMLHTTP = new XMLHttpRequest ();
}
else{
Xmlttp = new ActiveXObject ("Microsoft.XMLHTTP");
}
Xmlhttp.open (Method,url,async);
Xmlhttp.setrequestheader ()
Xmlhttp.onreadystatechange = function () {
if (Xmlhttp.readystate ==4&&xmlhttp.status==200) {
Xmlhttp.getresponseheader (String)
Xmlhttp.responsexml
Xmlhttp.responsetext
}
}
Xmlhttp.send (string);
---------------------------------------------------------------------------------------------------------
&.ajax ({
Type: "GET",
URL: "/http",
Success:function (msg) {},
Error:function (Xmlhttprequest,textstatus,errorthrow) {},
statuscode:{
404:function () {}
},
Complete:function (xmlhttprequest,textstatus) {}
});
Normally, Ajax sends data to the specified URL in a specified way, and when the server finishes processing it returns status 200, and Content-type:text/plain data, the client receives the returned data for processing. If the session expires when the AJAX data is sent, the server requires redirection to the landing page, and the foreground does not get a status code of 302, and the XMLHttpRequest object initiates a redirect request directly to the background and then returns the status 200,content-type: Text/html;msg and ResponseText are the HTML for landing pages.
In complete, the page is displayed if the returned Content-type is text/html
document.write (Xmlhttprequest.responsetext);
Document.close ();(required)
If the AJAX request is sent in a nested page, the landing page is displayed in the topmost page and can be called in the login page
if (top.location! = window.location) {
Top.location = window.location;
}
Prevents page nesting.
Ajax about Redirection