<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>