ajax 提交加入遮罩

来源:互联网 发布:2017年8月宏观数据 编辑:程序博客网 时间:2024/05/27 21:01

ajax 提交加入遮罩


ajax 如果采用  sync:false 那么遮罩不能够显示, 不可以是同步的,这是一个致命的弊端


js:

$(document).ready(function(){
$(document).ajaxStart(function(){
$("body").mLoading('show');
});
$(document).ajaxStop(function(){
$('body').mLoading('hide');
});
$('#btn').click(function(){
$.ajax({
url:'/fastMC/test',
type:'post',
dataType:'json',
success:function(data){
$('#searchName').val(JSON.stringify(data))
}


});
});

});


// global:false, will not show


<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /><link href="../fastMC/css/jquery.mloading.css" rel="stylesheet"><script src="../fastMC/js/jquery-2.1.4.min.js"></script><script type="text/javascript" src="../fastMC/js/jquery.mloading.js"></script><script type="text/javascript" src="../fastMC/js/testLoading.js"></script><title>ajax - test</title></head><body style="overflow: hidden"><button id="btn">点击</button><input id='searchName' ></body></html>


0 0
原创粉丝点击