• ajax请求加载Loading或错误提示


        <div id="loadingDiv" style="color:#f39800;">Loading...</div>
    
    
    <script type="text/javascript">
        
        var $loading = $('#loadingDiv').hide();
            $(document).ajaxStart(function () {
                  $('#loadingDiv').css("position", "absolute");
                  $('#loadingDiv').css("top", Math.max(0, (($(window).height() - $('#loadingDiv').outerHeight()) / 2) +
                                                            $(window).scrollTop()) + "px");
                  $('#loadingDiv').css("left", Math.max(0, (($(window).width() - $('#loadingDiv').outerWidth()) / 2) +
                                                            $(window).scrollLeft()) + "px");
                  $('#loadingDiv').show();
              })
              .ajaxStop(function () {
                  $('#loadingDiv').hide();
              });
            $(document).ajaxError(function (event, jqXHR, request, settings) {
                var text = jqXHR.statusText + "(" + jqXHR.status + ")";
                if (jqXHR.responseJSON)
                    text = jqXHR.responseJSON.message;
                 alert('操作出现异常:' + text + '重试后仍出现请联系开发');
            });
    </script>
  • 相关阅读:
    String系列
    java初始化构造函数调用顺序
    转发和重定向的区别
    HttpServletResponse对象
    JSP九大隐式对象
    关于异常
    MySQL下载、安装及启动
    MySQL的启动
    MySQL下载及安装
    U盘安装Win7操作系统
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/5335631.html
Copyright © 2020-2023  润新知