“异步:假"是什么意思?在 jQuery.ajax() 中做什么? [英] What does "async: false" do in jQuery.ajax()?

查看:33
本文介绍了“异步:假"是什么意思?在 jQuery.ajax() 中做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具体来说,它与默认( async: true )有何不同?

Specifically, how does it differ from the default ( async: true ) ?

在什么情况下我要显式设置 asyncfalse,这是否与阻止页面上的其他事件触发有关?

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 ,则该语句将开始执行,并且无论异步语句是否已完成,都将调用下一条语句.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆