您的位置:首页 > Web前端 > JQuery

jquery 采用async:false同步加载数据

2013-03-27 16:21 302 查看
使用jquery的ajax去进行某些操作,默认是异步加载的方式。即在执行ajax对应后台操作时,前台的JS也会继续执行,并不会等jquery的ajax执行结束。有些情况下可能必须等到ajax执行完毕,才接着执行下面的语句的时候,需要在ajax中,加入一个参数: async:false。这样ajax就会采用同步的方式执行,等到ajax执行完毕再接着执行下面的语句。
async
Boolean

Default: true

By default, all requests are sent asynchronous (e.g. this is set to true by default). If you need synchronous requests, set this option to false. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is
active.

参考:http://www.cnblogs.com/xmphoenix/archive/2011/11/21/2257651.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jquery