I have a code which show loading spinner:
$(document)
.ajaxStart(function () {
var indicator = $('#busyIndicator');
indicator.show();
})
.ajaxStop(function () {
var indicator = $('#busyIndicator');
indicator.hide();
})
And I have a function fires on form success:
function onSuccess() {
$('#busyIndicator').show();
}
This is html(some code and attributes is omitted):
<div id="busyIndicator" style="display: none;">
<img alt="" src="/Images/Animation/steamtrain.gif">
</div>
<form method="post" id="createForm" data-ajax-success="onSuccess" data-ajax-method="POST" data-ajax="true">...</form>
The onSuccess
function is called, but the image not visible. I tryed to insert debugger
after this line:
$('#busyIndicator').show();
In this case the image is visible. I think the problem in that ajaxStop
fires after onSuccess
. I can change code only in the onSuccess
function. How to solve it?