Ajax knowledge notes-getting started, synchronous and asynchronous, XHR, ajaxxhr

Source: Internet
Author: User

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}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.