什么是“异步:假"?在jQuery.ajax()中做什么? [英] What does "async: false" do in jQuery.ajax()?
问题描述
具体来说,它与默认值(async: true
)有何不同?
Specifically, how does it differ from the default ( async: true
) ?
在什么情况下我想将async
显式设置为false
,它与防止页面上的其他事件触发有关系吗?
In what circumstances would I want to explicit set async
to false
, and does it have something to do with preventing other events on the page from firing ?
推荐答案
与它有关吗 防止页面上发生其他事件 开火?
Does it have something to do with preventing other events on the page from firing?
是的
将async设置为false意味着要调用的语句必须先完成,然后才能调用函数中的下一条语句.如果您设置async:true,则该语句将开始执行,而无论async语句是否已完成,都将调用下一条语句.
Setting async to false means that the statement you are calling has to complete before the next statement in your function can be called. If you set async: true then that statement will begin it's execution and the next statement will be called regardless of whether the async statement has completed yet.
有关更多信息,请参见: jQuery ajax成功匿名函数作用域
For more insight see: jQuery ajax success anonymous function scope
这篇关于什么是“异步:假"?在jQuery.ajax()中做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!