我想知道,呈现出装载GIF到一个特定的jQuery Ajax请求的最简单的方法。
I want to know the easiest way of showing a 'loading' gif to a specific jquery ajax request.
我已经尝试过:
$(document).ajaxStart(function() {
$('.hideOnLoad').hide();
});
$(document).ajaxStop(function() {
$('.hideOnLoad').show();
});
但后来所有的Ajax请求将触发它。我只想要一个特定的jQuery Ajax请求触发装载过程(也许GIF将显示)。
but then ALL ajax requests will trigger it. i just want a specific jquery ajax request to trigger the loading process (maybe a gif will be shown).
我该怎么办呢?
在 beforeSend
回调,你必须表现出微调和完整
你必须把它藏起来。仅供参考: ajaxStart
和 ajaxStop
是全球性的AJAX事件,而 beforeSend
和完整
是本地的。
In beforeSend
callback you have to show the spinner and in complete
you have to hide it. Just FYI: ajaxStart
and ajaxStop
are global ajax events while beforeSend
and complete
are local.