$.mobile.loading('show') usage

$.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').

  1. $(document).bind('pageinit', function() {
  2.             $.ajax({
  3.               url: 'http://testserver/data',
  4.               type: 'GET',
  5.               dataType: 'json',
  6.               beforeSend: function() { $.mobile.loading('show') },
  7.               complete: function(jqXHR, textStatus) { $.mobile.loading('hide'); }
  8.             });
  9.         });
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