web弹框/层 (layer )的使用

首先引入:layer.css和layer.js

链接:https://pan.baidu.com/s/18MlzXBfRxhoeYzlokumdGg 密码:t046

基本使用:

$.ajax({
         type : "post",
         url : '路径',   
         async:false,//false为同步,同步会锁住浏览器,待ajax执行完毕后执行下面的语句,一般都是异步(最好不要采用同步),默认为异步及async:true或者什么都不写
         dataType : "json",    
         data:{参数1:值1,    参数2:值2},
         //下面beforeSend为layer的弹出层
         beforeSend: function (xhr, self) {
             layer.load(2, {
                 shade: [0.1, '#eee'] //0.1透明度的白色背景
             });
         },
         success : function(res) { 
            var data = res.data;
             if(res.success){
                //返回成功
             }else{
                //返回失败
                layer.msg(data);//弹出错误信息
             }
             //关闭loading
            layer.closeAll('loading'); 
         },
         //ajax出错提醒
         error: function (result) {
           layer.msg("获取业务受理数据失败!");
       }
    });
原文地址:https://www.cnblogs.com/gaomanito/p/8889522.html