layui 操作后跳窗提醒,后台请求返回关闭跳窗一个方法

function xxaa(ItemID, type, UserID_Violate,table ) {
    var info = "";
    if (type == 'S') {
        info = "ss交易为【xvb违约】么?";
    } else if (type == 'B') {
        info = "ss定该交易为【cbd违约】么?";
    } else {
        info = "sss交易无人违约么?取消交易";
    }
    layer.confirm('<span style="position: relative;top: -70px;display: inline-block;margin-right: 20px;">备注</span>&nbsp;<textarea rows="5" cols="35" id="as_ReasonY"></textarea>', 
        {
        title: info,
        btn: ['通过', '取消']
      },function(index){
        //调用后台
         $.ajax({
               type : 'POST',
               url : 'xxxx',
               dataType : 'json',
               data: {"CoinsTradeID": ItemID, "type": type, "UserID_Violate": UserID_Violate, "remark": $("#as_ReasonY").val() },
               success:function(data){
                 if(data.res=="ok"){
                    layer.alert('操作成功!', function(index){
                         layer.close(index);
                         table.reload('testReload', {
                            where: {
                               status:$('#TradeStatus').val()
                              ,startDate:startDate
                              ,endDate:endDate
                              ,fc_SellerName:$('#fc_SellerName').val()
                              ,fc_BuyerName:$('#fc_BuyerName').val()
                            }
                          });
                    });    
                 }else{
                    layer.alert(data.res, function(index){
                       layer.close(index);
                       table.reload('testReload', {
                          where: {
                             status:$('#TradeStatus').val()
                            ,startDate:startDate
                            ,endDate:endDate
                            ,fc_SellerName:$('#fc_SellerName').val()
                            ,fc_BuyerName:$('#fc_BuyerName').val()
                          }
                        });
                    });
                 }
               },
             error:function(e){
                console.log(e);
             }    
       }); 
        //obj.del();
        layer.close(index);
      });
  
}
原文地址:https://www.cnblogs.com/zuochanzi/p/13949653.html