Ajax Synchronous and asynchronous

Source: Internet
Author: User

Ajax is performed asynchronously by default, that is, its properties Async:boolean (asynchronous);

The difference between synchronous and asynchronous:

Synchronization: Client requests data to the server until that part of the data is returned, the corresponding program queue of the client after requesting the return value is executed sequentially, during which the client is in suspended animation;

Async: Cilent requests data to the server, Cilent is active, the program queue continues to execute, and the corresponding cilent response is inserted into the program sequence after the server returns the data.

Eg:a,b[cilent sends a request to the server],c[server returns the request result],d,e to the client (where A,d,e is the client program executed sequentially);

Synchronization process: A--B--C--D--E; D will be executed after C, exactly in order;

Asynchronous process: A--B--D--E--c (possible result); After B sends the request execution, D does not wait, but directly after B executes, C's result return may after D, may also before D, is after has the result to insert the program queue;

Therefore, it is recommended to use synchronous mode when it comes to other program queues in cilent that may use server data that is requested by Ajax, because using async might have the server data in the queue other programs, and that data is still returned, resulting in undefined undefine errors.

Ajax Synchronous and asynchronous

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.