<!DOCTYPE html>
<html>
<head>
<title>Ajax Loading Demo</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
</style>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="layer/layer.js"></script>
<script type="text/javascript">
;!function(){
layer.config({//加载扩展模块
extend: 'extend/layer.ext.js'
});
layer.ready(function(){
});
}();
function ityzl_SHOW_LOAD_LAYER(){
return layer.msg('努力中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '0px', time:100000}) ;
}
function ityzl_CLOSE_LOAD_LAYER(index){
layer.close(index);
}
function ityzl_SHOW_TIP_LAYER(){
layer.msg('恭喜您,加载完成!',{time: 1000,offset: '10px'});
}
</script>
<script type="text/javascript">
$(function(){
$("#btnRequest").bind("click", function () {
var i ;
$.ajax({
type: "POST",
dataType: "text",
url: "admin/index.action",
beforeSend: function () {
i = ityzl_SHOW_LOAD_LAYER();
},
success: function (msg) {
ityzl_CLOSE_LOAD_LAYER(i);
ityzl_SHOW_TIP_LAYER();
},
error: function (e, jqxhr, settings, exception) {
ityzl_CLOSE_LOAD_LAYER(i);
}
});
});
});
</script>
</head>
<body>
<a href="javascript:void(0);" id="btnRequest" >请求数据</a>
</body>
</html>layer加载遮罩层使用 Ajax Loading Demo
使用layer实现Ajax加载遮罩层示例
最新推荐文章于 2025-09-11 02:21:26 发布
此博客展示了如何使用layer库结合Ajax创建一个加载遮罩层的效果。通过点击按钮触发Ajax请求,在请求开始时显示加载提示,请求完成后关闭加载层并显示完成提示。代码中详细解释了配置layer、定义加载和关闭加载层以及提示层的方法。
533

被折叠的 条评论
为什么被折叠?



