发布于:Ajax

Ajax 事件

通常,您会希望在 Ajax 请求开始或停止时执行某些操作,例如显示或隐藏加载指示器。与其在每个 Ajax 请求中定义这种行为,不如像绑定其他事件一样,将 Ajax 事件绑定到元素上。有关 Ajax 事件的完整列表,请访问 docs.jquery.com 上的 Ajax 事件文档

1
2
3
4
5
6
7
8
// Setting up a loading indicator using Ajax Events
$( "#loading_indicator" )
.ajaxStart(function() {
$( this ).show();
})
.ajaxStop(function() {
$( this ).hide();
});