Ajax knowledge notes-getting started, synchronous and asynchronous, XHR, ajaxxhr
Ajax Full name: Asynchronous Javascript and XML, Asynchronous javascript and XML.
Ajax is not a language, but a technology that updates some webpages without the need to reload the entire webpage.
(Interacts with the background to implement local update and asynchronous update)
Synchronous and asynchronous:
Synchronization (before Ajax): When a client initiates a request, the server processes and responds to the request. During this period, the client waits for the response from the server. After receiving the response from the server, the client reloads the page. If you have any errors, you can only initiate a request again and wait again ......
Asynchronous (after Ajax): The emergence of XMLHttpRequest enables the backend and server to exchange data without reloading the page (and partially update the page ).
XMLHttpRequest
Instantiate an XHR object:
<Span style = "font-family: SimSun; font-size: 12px;"> var request </span> <span style = "font-family: Microsoft Yahei, hiragino Sans GB, Helvetica, Helvetica Neue,, Tahoma, Arial, sans-serif; font-size: 14px; ">=</span> <span style =" font-family: SimSun; font-size: 12px; "> new XMLHttpRequest (); </span>
Browser compatibility considerations:
var request;if(window.XMLHttpRequest){request = new XMLHttpRequest();//IE7+,Firefox,Chrome,Opera,Safari…}else{request = new ActiveXObject("Microsoft.XMLHTTP");//IE6,IE5}