ajax 启动时 Jquery 阻止 UI
我试图在 ajax 启动时显示 blockui,如下所示:
// block when ajax activity starts
$(document).ajaxStart($.blockUI({ message: '<h1><img src="busy.gif" /> Just a moment...</h1>' }));
然后我想停止它执行
// unblock when ajax activity stops
$(document).ajaxStop($.unblockUI);
问题是,执行 ajax 时它不会加载,我做错了什么?
I am trying to show blockui when ajax starts like so:
// block when ajax activity starts
$(document).ajaxStart($.blockUI({ message: '<h1><img src="busy.gif" /> Just a moment...</h1>' }));
and then I want to stop it doing
// unblock when ajax activity stops
$(document).ajaxStop($.unblockUI);
Problem Is that it won't load when ajax is performed what have I done wrong'??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您需要像这样更改它:
当您需要将参数传递给要绑定的函数时,您应该使用匿名函数,然后在其中调用您的方法。 $.blockUI() 返回不可调用的内容,因此以这种方式绑定它不起作用。
I think you need to change it like so:
When you need to pass parameters to the function you want to bind you should use an anonymous function and then call your method inside it. $.blockUI() returns something which is not callable, so it doesn't work to bind it that way.
根据 jQuery 文档:
那么也许您还有其他 AJAX 请求阻止此事件触发?
According to the jQuery documentation:
So perhaps you have other AJAX requests that are preventing this event from firing?