且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何呼叫警报所有Ajax请求完成后?

更新时间:2022-06-04 06:49:45

您可以使用延期对象 [文档] jQuery的1.5介绍:

You can make use of deferred objects [docs] introduced in jQuery 1.5:

$.when(
    $.get('address1', function() { ... }),
    $.get('address2', function() { ... }),
    $.get('address3', function() { ... })
).then(function() {
    alert('Finished');
});

参考: jQuery.when

jQuery的学习中心有一个很好的介绍推迟对象/ 的承诺

The jQuery learning center has a nice introduction to deferred objects / promises.