These other solutions are great, but I'm not sure if they are addressing your issue calling for CSS $("#loader") changes in startup and success .
Maybe something like this:
$(document).ajaxStart(function() { // do something on start $("#loader").css("display","block"); }).ajaxError(function(e, xhr, settings) { // do something on error $("#loader").css("display","none"); }).ajaxSuccess(function() { // do something on success $("#loader").css("display","block"); });
Check out this correctly working example: http://jsbin.com/ocovoq/3/edit#preview
shanabus
source share