Jquery Block ui 仅在函数的 ajaxStart 上显示
我目前正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须从通用 ajaxStart 和 ajaxStop 事件中取出阻塞/解除阻塞,并根据具体情况进行阻塞/解除阻塞:
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: