layer插件loading快速应用示例

时间:2023-01-28 00:17:53

1、页面引用
<link rel="stylesheet" href="../Js/layer/skin/layer.css"  />
<script type="text/javascript" src="../Js/layer/layer.js"></script>

2、ajax请求中应用
<script type="text/javascript">
var loadingFlag;
$.ajax({
    url: "../FlightHandler/JDFlightHandler.ashx",
    type: "post",
    data: info,
    dataType: "text",
    beforeSend: function (XMLHttpRequest) {
        //注意,layer.msg默认3秒自动关闭,如果数据加载耗时比较长,需要设置time
        loadingFlag= layer.msg('正在读取数据,请稍候……', { icon: 16, shade: 0.01,shadeClose:false,time:60000 });
    },
    success: function (data) {
    
            layer.close(loadingFlag);
    },
    complete: function (XMLHttpRequest, textStatus) {

},
    error: function (XMLHttpRequest, textStatus, errorThrown) {

}
});
</script>

参考:
http://www.layui.com/doc/modules/layer.html
http://blog.csdn.net/responsecool/article/details/50506736