layui加載層的寫法


 
         
  1. <script type="text/javascript" src="jquery-1.8.3.min.js"></script>  
  2.     <script type="text/javascript" src="layer/layer.js"></script>  

//在js中寫出前后加載的函數 加載層
1
; !function () { 2 layer.config({//加載擴展模塊 3 extend: '../lib/jquery.plugins/layer/extend/layer.ext.js' 4 }); 5 layer.ready(function () { 6 }); 7 }(); 8 9 function ityzl_SHOW_LOAD_LAYER() { 10 return layer.msg('努力中...', { icon: 16, shade: [0.5, '#f5f5f5'], scrollbar: false, offset: '50%', time: 300000 }); 11 } 12 function ityzl_CLOSE_LOAD_LAYER(index) { 13 layer.close(index); 14 } 15 function ityzl_SHOW_TIP_LAYER() { 16 layer.msg('恭喜您,加載完成!', { time: 1000, offset: '50%' }); 17 }
 1 //ajax做處理 當然 也可以是點擊事件。
 2 var i;
 3         $(function () {
 4             $.ajax({
 5                 type: "POST",
 6                 dataType: "text",
 7                 url: "",
 8                 beforeSend: function () {
 9                    i = ityzl_SHOW_LOAD_LAYER();
10                 },
11                 success: function (msg) {
12                     ityzl_CLOSE_LOAD_LAYER(i);
13                     ityzl_SHOW_TIP_LAYER();
14                 },
15                 error: function (e, jqxhr, settings, exception) {
16                     ityzl_CLOSE_LOAD_LAYER(i);
17                 }
18             });
19         });

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM