jquery ajaxStart() ajaxComplete()
http://www.w3school.com.cn/tiy/t.asp?f=jquery_ajax_ajaxstart
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").ajaxStart(function(){
$(this).html("<img src='/i/demo_wait.gif' />");
}).ajaxComplete(function(){
$("#show").html("<img src='/i/demo_wait.gif' />");
});
$("button").click(function(){
$("div").load("/example/jquery/demo_ajax_load.asp");
});
});
</script>
</head>
<body>
<div id="txt"><h2>通过 AJAX 改变文本</h2></div>
<button>改变内容</button>
<div id="show"></div>
</body>
</html>
定义和用法:
ajaxStart() 方法在 AJAX 请求发送前执行函数。它是一个 Ajax 事件。
详细说明
无论在何时发送 Ajax 请求,jQuery 都会检查是否存在其他 Ajax 请求。如果不存在,则 jQuery 会触发该 ajaxStart 事件。在此时,由 .ajaxStart() 方法注册的任何函数都会被执行。
定义和用法
ajaxComplete() 方法在 AJAX 请求完成时执行函数。它是一个 Ajax 事件。
与 ajaxSuccess() 不同,通过 ajaxComplete() 方法规定的函数会在请求完成时运行,即使请求并未成功。