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

async The default is true, which is asynchronous mode. After $.Ajax is executed, the script behind ajax will continue to be executed until the server returns data. Finally, the success method in $.Ajax is triggered. At this time, two threads are executed. If you set it to false, all requests are synchronous requests. Before there is no return value, the synchronous request will lock the browser, and the user other operations must 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

async is false, the code is blocked until the ajax call returns, so done (i.e. success) is executed first and then the sentence console.log after the ajax call is executed.

When

async is true (default), the code is not blocked, so the following console.log is executed first, and then the console.log in done is 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

学霸

$.Ajax The js script behind. (Better not to use the word script)

迷茫

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