2

我正在尝试使用 jQuery Mobile 为我的页面设置微调器加载。但是,当我使用 Ajax 加载某些内容时,微调器不会显示自己。这是我的代码。有什么想法有什么问题吗?

$("#invite").live('pageinit', function(e) {
  var render = function (items) {
    var view = '',
    index = 0;
    items.forEach(function(date){
      view +=
        '<div class="ui-block" style="background:white;">' +
        date.address
        '</div>';
      index++;
    });
    return view;
  };
  $.mobile.showPageLoadingMsg();
  $.ajax({                  
    url: 'someurl.com/file.json',
    dataType: "json",
    success: function(data) {
      $('#list').html(render(data.shared_dates));
      $.mobile.hidePageLoadingMsg();
    }
  })
});
4

2 回答 2

3

如果您使用的是 jQuery Mobile 1.2,那么您应该使用以下内容:

$.mobile.loading( 'show' )

$.mobile.loading( 'hide' )

文档:http: //jquerymobile.com/demos/1.2.0/docs/api/methods.html

于 2012-11-23T09:05:20.927 回答
2

我正在使用此代码来实现:

       $.ajax({url: server_url,
        data: save_data,
        dataType: "jsonp",
        jsonpCallback: 'successCallback',
        async: true,
        beforeSend: function() {
            $.mobile.showPageLoadingMsg(true);
        },
        complete: function() {
            $.mobile.hidePageLoadingMsg();
        },
        success: function (result) {
            // some code here
        },
        error: function (request,error) {
            // some code here
        }, 
       successCallback:function(){

        }
    });

这是 jsonp 的示例,但逻辑仍然相同。

于 2012-11-23T23:03:30.833 回答