This article mainly introduces the role of Ajax interpretation, so that we can more clearly use Ajax, now let's look at this article together
AJAX is a technique that can update parts of a Web page without reloading the entire page.
No flush data Read
User login, Stock Fund network
Asynchronous, synchronous
AJAX = Asynchronous JavaScript and XML (asynchronous JavaScript and XML). AJAX is not a new programming language, but a new method of using existing standards.
AJAX is the art of exchanging data with a server and updating parts of a Web page without reloading the entire page. There are many examples of applications that use AJAX: Sina Weibo, Google maps, happy net, and more. (Want to see more on the Topic.alibabacloud.comAJAX Development Manual section of the study)
Traditional development mode: each operation of the user triggers an HTTP request to return the server once, and after the server has processed it, it returns an HTML page to the user.
Ajax Development Mode: The page communicates the user's actions through the AJAX engine to the server, returns the results to the Ajax engine, and then Ajax inserts the data into the specified location.
Writing Ajax functions
1. Creating Ajax Objects
var xmlhttp;if (window. XMLHttpRequest) {//code for ie7+, Firefox, Chrome, Opera, safarixmlhttp=new XMLHttpRequest ();} else{//code for IE6, ie5xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");}
2. Connect to the server
Xmlhttp.open (' GET ', url,true);//Three parameters represent the method, path, synchronous, or asynchronous (true is asynchronous), respectively;
3. Send Request
Xmlhttp.send ();
4. Receive return value
Xmlhttp.onreadystatechange=function () {if (xmlhttp.readystate==4) {if (xmlhttp.status==200) {alert (' success: ' + Oajax.responsetext);} Else{alert (' failure: ' +oajax.status);}}} Encapsulated into function functions Ajax (URL, fnsucc, fnfaild) {//1. Create an Ajax object if (window. XMLHttpRequest) {var oajax=newxmlhttprequest ();} Else{var oajax=newactivexobject ("Microsoft.XMLHTTP");} 2. Connect Server//open (method, file name, asynchronous transfer) Oajax.open (' GET ', url,true);//3. Send Request Oajax.send ();//4. Receive Return oajax.onreadystatechange= function () {//oajax.readystate//browser and server, to which step the IF (oajax.readystate==4)//Read Complete {if (oajax.status==200)//Success {FNSUCC ( Oajax.responsetext);} Else{if (fnfaild) {fnfaild (oajax.status);} Alert (' Failure: ' +oajax.status ');}};}
This is the end of this article (want to see more on the Topic.alibabacloud.comAJAX User manual section of the study), there are questions can be in the message below the question.