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

查看:32
本文介绍了“async: false"是什么意思?在 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

这篇关于“async: false"是什么意思?在 jQuery.ajax() 中做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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