I know how to do this with
$(gif).show();
$.post( action, data, function(result) { $(gif).hide(); } );
// using ajaxStart and ajaxStop is a better way too
But, I don't know how to do it without using post, I tryed
$(gif).show();
doAction(); // No post...
$(gif).hide();
The problem is, while doAction function is running the $(gif) isn't visible .... I tryed with timeouts too, but the problem is that ends before or after depending of the doAction() duration...