zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    python-字典
    python-列表
    python:基础数据类型
    前端之JS
    数据库之备份,恢复
    前端之CSS
    前端之CSS笔记
    前端之html
    数据库之操作使用python操作mysql数据库
    何为javaBean?
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/5335631.html
Copyright © 2011-2022 走看看