javascript - Questions about ajax asynchronous
typecho
typecho 2017-07-05 10:52:26
0
4
931

asyncThe default istrue, which is asynchronous mode. After$.Ajaxis executed, the script behind ajax will continue to be executed until the server returns data. Finally, the success method in$.Ajaxis triggered. At this time, two threads are executed. If you set it tofalse, all requests are synchronous requests. Before there is no return value, the synchronous request will lock the browser, and the userother operationsmust wait for the request to be completed. before it can be executed.

What are the specific examples of this other operation? Does it refer to http request or js script?

typecho
typecho

Following the voice in heart.

reply all (4)
Peter_Zhu

First picture

When

asyncisfalse, the code is blocked until the ajax call returns, sodone(i.e.success) is executed first and then the sentenceconsole.logafter the ajax call is executed.

When

asyncistrue(default), the code is not blocked, so the followingconsole.logis executed first, and then theconsole.logindoneis executed after ajax returns.

    曾经蜡笔没有小新

    指js脚本
    http://transcoder.tradaquan.com/from=2001a/bd_page_type=1/ssid=0/uid=0/pu=usm%401%2Csz%401320_2003%2Cta%40iphone_1_10.3_1_11.5/baiduid=3ECCA1E6D2665DB48EFEBB60D9D9084F/w=0_10_/t=iphone/l=3/tc?ref=www_iphone&lid=8260698868132866872&order=1&fm=alhm&h5ad=1&srd=1&dict=32&tj=h5_mobile_1_0_10_title&w_qd=IlPT2AEptyoA_yivDVKcCTpsvgzWOeIntjcXa3jSqfgrUO_&sec=21456&di=8e54227838fdccf9&bdenc=1&nsrc=IlPT2AEptyoA_yixCFOxXnANedT62v3IEQGG_ytK1DK6mlrte4viZQRAVDb6QHOTCU8sumX0sqdFtXLR_7Mi8xR_qbIwdzZz

      学霸

      $.AjaxThe js script behind. (Better not to use the wordscript)

        迷茫

        If ajax is synchronous, it means that js is executed sequentially, http requests are sent by ajax, and js is js. Don’t confuse them together.
        Other user operations should refer to the user triggering js-related operations. If there is time to bind an element behind ajax, it can be triggered.
        The final summary is that when the current js script is synchronous ajax, the script is executed sequentially; when asynchronous ajax is used, it is executed asynchronously. The so-called asynchronous execution means that when ajax is executed, the js statement after ajax is directly executed without waiting for the request to return.

          Latest Downloads
          More>
          Web Effects
          Website Source Code
          Website Materials
          Front End Template
          About us Disclaimer Sitemap
          php.cn:Public welfare online PHP training,Help PHP learners grow quickly!