方法1:使用ajaxStart方法定义一个全局的“加载中。。。”提示
$(function(){
$("#loading").ajaxStart(function(){
$(this).html("<img src='/jqueryStu/images/loading.gif' />");
});
$("#loading").ajaxSuccess(function(){
$(this).html("");
// $(this).empty(); // 或者直接清除
});
});
<div ></div>
很明显,在beforeSend时,在指定的位置显示“加载中。。。”图标,在error、complete、success后把该图标移除掉!!!!
注意:
页面有多个ajax提交时候,建议使用第二种方式,因为“加载中。。。”图标可以显示在任意你需要刷新的位置上!!!!!这就是它的优势:自由呀!!!!
相关文章: