JQuery多个异步操作后执行(resolve,promise,when,done)
生活随笔
收集整理的這篇文章主要介紹了
JQuery多个异步操作后执行(resolve,promise,when,done)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
代碼分享:
//3秒后完成 function asyncThing1() {var dfd = $.Deferred();setTimeout(function () {alert('asyncThing1 seems to be done...');dfd.resolve('111');}, 3000);return dfd.promise(); } //5秒后完成 function asyncThing2() {var dfd = $.Deferred();setTimeout(function () {alert('asyncThing2 seems to be done...');dfd.resolve('222');}, 5000);return dfd.promise(); } //1秒后完成 function asyncThing3() { var dfd = $.Deferred();setTimeout(function () {alert('asyncThing3 seems to be done...');dfd.resolve('333');}, 1000);return dfd.promise(); } //全部完成后 $.when(asyncThing1(), asyncThing2(), asyncThing3()).done(function (res1, res2, res3) {alert('all done!');alert(res1 + ', ' + res2 + ', ' + res3); })?
轉載于:https://www.cnblogs.com/kandyvip/p/10948902.html
總結
以上是生活随笔為你收集整理的JQuery多个异步操作后执行(resolve,promise,when,done)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [BZOJ 2054]疯狂的馒头
- 下一篇: django ORM相关的那些操作汇总