在与后台交互时,用时过长、禁止页面操作等,有提示,增强页面体验:
$.ajax({
type:'POST',
url:url,
data:obj,
dataType:'json',
beforeSend: function () {
load("提示");
},
complete: function () {
disLoad();
},
success:function(data){
showMessage(data);
}
});
}
//弹出加载层
function load(msg) {
$("<div
class=\"datagrid-mask\"></div>").css({ display: "block", width:
"100%", height: $(window).height() }).appendTo("body");
$("<div
class=\"datagrid-mask-msg\"></div>").html(msg).appendTo("body").css({
display: "block", left: ($(document.body).outerWidth(true) - 190) / 2,
top: ($(window).height() - 45) / 2 });
}
//取消加载层
function disLoad() {
$(".datagrid-mask").remove();
$(".datagrid-mask-msg").remove();
}