I am having some problems with jQuery Variables. As I am kind of a newbie, maybe I am doing something wrong, but here it is:
var loading = jQuery('#loading');
loading.hide();
jQuery(document)
.ajaxStart(function () {
loading.show();
})
.ajaxStop(function () {
loading.hide();
});
What I am trying to do is, show my "loading" div while ajax is running, but the variable "loading" just seem to not work. If I use jQuery('#loading') everywhere instead of the variable it is working fine. What am I doing wrong?