Show:

bui.all Class

Module: Native

Available since 1.5.4

数据多个请求以后的处理.

Constructor

bui.all

(
  • option
)

Defined in src/scripts/mix/web/bui.ajax.js:410

Available since 1.5.4

Parameters:

  • option Array

    [数组里面必须为一个 promise 对象]

Example:

   var ajaxGetList = bui.get("http://www.easybui.com/demo/json/shop.json");
                                       var ajaxGetList2 = bui.get("http://www.easybui.com/demo/json/shop2.json");
                                       // 模拟失败请求
                                       var ajaxGetList3 = bui.post("http://www.easybui.com/demo/json/shop2.json");
                                    
                                       // 例子1: 等2个请求都结束以后才会进入回调
                                       bui.all([ajaxGetList,ajaxGetList2]).then(function(res1,res2){
                                           console.log(res1)
                                           console.log(res2)
                                       },function(res,status){
                                           console.log(status);
                                       })
                                    
                                       // 如果2个请求都成功,则进入then, 如果有一个请求 ajaxGetList3 失败,则会进入always
                                       bui.all([ajaxGetList, ajaxGetList3]).then(function(res, res2) {
                                           console.log(res);
                                           console.log(res2);
                                       }).always(function(res, res2) {
                                           console.log(res, "always");
                                           console.log(res2, "always");
                                       })
                                    

Item Index