web彈框/層 (layer )的使用
阿新 • • 發佈:2018-04-20
pan PE sync 錯誤 背景 div 語句 eal 關閉
首先引入:layer.css和layer.js
基本使用:
$.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("獲取業務受理數據失敗!"); } });
web彈框/層 (layer )的使用