【发布时间】:2014-03-18 15:31:59
【问题描述】:
我有一大堆 $.ajax 请求需要在启动之前相互等待。我知道 async : false 选项已被弃用,而且我也知道如果我将后续函数粘贴在 .done 中,那么它的行为方式与 async : false 相同。然而,为了保持清洁,我想知道是否可以作为替代方案,我可以离开 .done 而无需额外的代码,只需从“上到下”订购我的 ajax:这会告诉 jquery 运行 ajax,then 执行 .done 中的任何内容(在我的情况下没有!),“模仿”异步:false?
举个例子:
$.ajax({type: 'POST',
data: cool_data : "cool_data",
url: 'somewhere_over_the_rainbow.php'
}).done(function(){
})
$.ajax({type: 'POST',
data: more_cool_data : "more_cool_data",
url: 'more_somewhere_over_the_rainbow.php'
}).done(function(){
})
谢谢!
【问题讨论】:
标签: javascript jquery ajax asynchronous