insert the loading spinner with .getJson

insert the loading spinner with .getJson

So that's what I'm trying to do...insert a spinner and hide it when the page content is loaded but it's not working.  Here's what I have:

  1. $('#mainNews').on('pageinit', function(event) {
  2.         $.mobile.showPageLoadingMsg();
  3. getNews();
  4. });
  5. function getNews() {
  6. $.getJSON('file.php', function(data) {
  7.             $.each(data, function (i, u){
  8.                   append-to-listview;
  9.             }
  10.       $('').listview('refresh');
  11.       $.mobile.hidePageLoadingMsg();
  12.       });
  13. }
This seems simple but I can't get it to work.