Ajax loading gif for long running queries?

Has anyone managed to display a loading gif for long running queries? We have some fairly complex long running methods and ideally we would like to show that the system is actually doing something whilst they are running. I could show/ hide an image on every method but was wondering if anyone had managed to bind to a global ajax event (or something more clever) so that i don't have to call it in every method.