$.mobile.loading('show') usage
I wrote the following code to load data. During the loading, I would like to show the loading spinner using $.mobile.loading('show').
- $(document).bind('pageinit', function() {
- $.ajax({
- url: 'http://testserver/data',
- type: 'GET',
- dataType: 'json',
- beforeSend: function() { $.mobile.loading('show') },
- complete: function(jqXHR, textStatus) { $.mobile.loading('hide'); }
- });
- });
The spinner is not showing at all with this code. However, when using $(document).ready() instead of $(document).bind('pageinit') (which is not correct with jQuery Mobile), the spinner is shown correctly.
Can anyone tell me what I am doing wrong? (using JQM 1.2.0 RC2)
Thanks.
Xavier