I have a page that, thanks to jQuery will automatically click the "Run Report" button under certain conditions. So, when the user goes to the page via the menu, they wait for x seconds and the results are returned. This works great...
However, I want to add an animation because some users are not aware anything is going on and I also would like to just show a spinner. The application is not yet "Ajaxified" and may never be. So I thought of a poor-mans way of doing it.
I have a
div
display: none;
.toggleClass
Are you using the jQuery ajax method to request the report? If so there is a function built into the standard ajax method.
$.ajax({
url: "/webservices/taskHelper.asmx/ArchiveTask",
data: '{taskId: 5}',
beforeSend: function () {
$("#spinner").show();
},
error: deft.ajaxError,
success: function (data) {
$("#spinner").hide();
}
});
The "beforeSend" function will execute when the link is clicked and continue to run until a response is recieved from the server. I use the beforeSend function to display my hidden div containing an animated gif. Works just fine. jQuery ajax docs