Ajax synchronous asynchronous mode

Source: Internet
Author: User


When ajax is obtained synchronously, ff and ie

1 2 3 <title> Ajax synchronization test </title>
4 <script src = "Scripts/jquery-1.4.1.js" type = "text/javascript"> </script>
5 <script type = "text/javascript">
6 $ (document). ready (AjaxTest );
7 function AjaxTest (){
8 var flag = 0;
9 // display and Load
10 $ ("# ajaxStatus"). text ("loading data please wait .......");
11 // ajax submission (synchronous Mode)
12 $. ajax ({
13 type: "get ",
14 url: "/FunctionPage. aspx ",
15 async: false,
16 cache: false,
17 data :"",
18 dataType: "html ",
19 success: function (ajaxData ){
20 flag = ajaxData;
21 $ ("# ajaxStatus"). text ("Data Loading completed! ");
22}
23 });
24 if (flag = 1 ){
25 // loading is completed
26 $ ("# ajaxStatus"). text ("synchronization Data Loading completed! ");
27}
28}
29 </script>
30 31 <body>
32 <div id = "ajaxStatus"> </div>
33 </body>
34 35

Description: gets the return value of FunctionPage. aspx. If the return value is 1, it indicates that synchronization loading is completed.

Case 1: in ie, the synchronization data loading is completed after the synchronous call is completed. No prompts are displayed during data loading, and ie is suspended.

Case 2: ff is normal. The execution sequence is as follows: Data Loading in progress-> ajax request execution-> Data Loading completed.

Conclusion: The synchronization mode in ie will lead to the assumption that ie is dead. This user experience is quite uncomfortable. I don't know if there is any better solution, so I will implement logic in asynchronous mode for the moment.

Async: true

Test code:/Files/skyangell/AjaxAsyncDemo.rar

 

Related Article

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.