Jquery Block ui 仅在函数的 ajaxStart 上显示

发布于 2024-08-22 02:48:48 字数 748 浏览 6 评论 0原文

我目前正在使用 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 函数时都会阻塞页面。我怎样才能让它只在执行某些功能时才出现

I am currently using Blockui to block the page and show a loading gif when an ajax function is being performed. See here:

$(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;                           

});

My problem is that this blocks the page everytime an ajax function is perform. How would I make it appear only when certain functions are being performed

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

£噩梦荏苒 2024-08-29 02:48:48

您必须从通用 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');
      });

You'll have to take the blocking/unblocking out of the generic ajaxStart and ajaxStop events and block/unblock on a case-by-case basis:

$.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');
      });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文