1

我目前正在使用 Blockui 来阻止页面并在执行 ajax 功能时显示加载 gif。看这里:

$(document).ready(function() { 
            //shows loading screen whilst posting via ajax
    $().ajaxStart(function() { 
        $.blockUI({ message: '<h1><img src="../images/layout/busy.gif" /> Just a moment...</h1>' });  });           
    $().ajaxStop($.unblockUI);                     

//Load table from table.php
//Timestamp resolves IE caching issue
var tsTimeStamp= new Date().getTime();
$.get('table.php',
      {action: "get", time: tsTimeStamp},
      function(data){
        $('#customertable').html(data).slideDown('slow');
      });
return true;                           

});

我的问题是每次执行 ajax 函数时都会阻塞页面。仅在执行某些功能时如何使其显示

4

1 回答 1

2

您必须从通用 ajaxStart 和 ajaxStop 事件中取出阻塞/解除阻塞,并根据具体情况阻止/解除阻塞:

$.blockUI({ message: '<h1><img src="../images/layout/busy.gif" /> Just a moment...</h1>' });
$.get('table.php',
      {action: "get", time: tsTimeStamp},
      function(data){
        $.unblockUI();
        $('#customertable').html(data).slideDown('slow');
      });
于 2010-02-25T21:10:10.097 回答