What jQuery Mobile documentation is lacking information regarding successful execution of:
$.mobile.loading('show');
and
$.mobile.loading('hide');
They will show ONLY during the pageshow
event. In any other case you need to wrap them into the setinterval
, like this:
In case you don't know anything about pageshow
and rest of jQuery Mobile page events take a look at this ARTICLE, it is my personal blog. Or find it HERE.
First, you will not be able to show/hide AJAX
loader without set interval. There's is only one situation where this is possible without and that is during the pageshow
event. In any other case setinterval
is needed to kick start the loader.
Here's a working example: http://jsfiddle.net/Gajotres/Zr7Gf/
var interval = setInterval(function(){
$.mobile.loading('show');
clearInterval(interval);
},1);
var interval = setInterval(function(){
$.mobile.loading('hide');
clearInterval(interval);
},1);