Reputation: 39
I used ajaxStart
and ajaxStop
to show and hide loading by this way:
$(document).ajaxStart(function () {
$.LoadingOverlay("show", {
fade:[100,100]
});
});
$(document).ajaxStop(function () {
$.LoadingOverlay("hide", {
fade: [100, 100]
});
});
this code works. but sometimes ajaxStop
function did not triggered, and you have to press F5 key to reload page. because showing loading from ajax start did not hide.
I can't find the problem.
my jQuery
version is 2.2.4.
Updated
I used ajaxComplete
Instead of ajaxStop
but, there was the same problem.
$(document).ajaxStart(function () {
$.LoadingOverlay("show", {
fade:[100,100]
});
});
$(document).ajaxComplete(function () {
$.LoadingOverlay("hide", {
fade: [100, 100]
});
});
Is there anything else, that would be useful?
Upvotes: 0
Views: 553
Reputation: 1589
use ajaxComplete
ajaxComplete is called whenever an ajax request finishes, either successfully or with an error.
ajaxStop is called when all ajax requests complete. So unlike ajaxComplete, it won't be called if there is still a request in progress.
You should use the first if the operation you want to perform should be done for every ajax request.
credit for @sje397 from https://stackoverflow.com/a/4419387/1475257
Upvotes: 1