JQuery BlockUI 阻止消息不会立即显示
我有以下代码 .net mvc aspx 页面 ...
//////////////////////
$.blockUI({ message: '
正在处理 ... 请稍候
' });var registerOk = registerNewUser(); var createUserSubscriptionOK = createUserSubscription();
$.unblockUI();
\\\\\\\\\\\\
块消息直到第二个函数完成时才会显示。 这两个函数都会收集表单数据,然后对数据库进行异步调用。
我需要立即显示消息,同时触发两个函数,然后一旦两个函数都完成,用户界面就会解锁......
我该怎么做?
感谢您的任何反馈。
I have the following code an .net mvc aspx page ...
//////////////////////
$.blockUI({ message: '
Processing ... Please Wait
' });
var registerOk = registerNewUser();
var createUserSubscriptionOK = createUserSubscription();
$.unblockUI();
\\\\\\\\\\\\
The block message does not show until just around the time that the 2nd function finishes.
Both functions gather form data then make asynch calls to the db.
I need the message to show immediately, have both functions fire, then once both are completed, the ui gets unblocked ...
How do I do this?
Thanks for any feedback.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您好,我对此没有答案,但我只是想报告我在 Firefox 3.5.9 中看到了同样的问题。
我正在尝试使用 blockUI 在服务器处理通过表单发送的信息时用动画 gif 显示等待消息。
里面的
$("#form").submit(function() {
首先我调用 blockUI:
$.blockUI({ message: -图片在这里- 正在处理您的请求,请稍候...' });
然后我准备要发送到服务器的数据并通过 ajax 同步调用将它们发布:
$.ajax({
类型:“帖子”,
url: '/submitForm/'+类型名称,
数据:postdata+"&"+sData,
缓存:假,
异步:假
});
最后我解锁了
$.unblockUI();
我注意到它与 Konqueror(在 KDE4 中)配合使用,它显示等待窗口,其中带有使背景变暗的动画 gif,并在最后消失。
因此,问题可能与 Firefox 有关,或者可能与某些不影响特定浏览器的错误配置有关。
我希望这些信息对一些专家弄清楚实际问题是什么很有用。
我也将感谢任何反馈。
编辑:
您好,
我不知道这是否仍然相关,但最终我设法让它发挥作用。问题是我正在使用 ajax 进行同步调用(submitForm 调用中的“async: false”位)。
BlockUI 被认为可以使异步调用像同步调用一样工作,即阻塞界面。如果调用已经是同步的,则无需阻止 ui,因为这是同步调用的正常行为!
所以对我来说,只需删除“async: false”部分就可以了。
我希望这有帮助。
Hi I don't have an answer for this, but I just wanted to report that I am seeing the same problem in firefox 3.5.9.
I am trying to use blockUI to show a wait message with an animated gif while the server processes the information sent through a form.
Inside the
$("#form").submit(function() {
first I call blockUI:
$.blockUI({ message: -image here- Processing your request, please wait...' });
Then I prepare the data to be sent to the server and post them with an ajax synchronous call:
$.ajax({
type: "POST",
url: '/submitForm/'+typeName,
data: postdata+"&"+sData,
cache: false,
async: false
});
and in the end I unlock
$.unblockUI();
I noticed that it works with Konqueror (in KDE4), it shows the wait window with the animated gif darkening the background and it disappears at the end.
So the problem might be related to firefox, or maybe to some misconfiguration that does not affect that particular browser.
I hope this information is useful to some expert in figuring out what the actual problem is.
I would also be thankful for any feedback.
EDIT:
Hello,
I don't know if this is still relevant, but in the end I managed to make it work. The problem was that I was doing a synchronous call with ajax (the "async: false" bit in the submitForm call).
BlockUI is thought to make an asynchronous call work as if it was synchronous, i.e. blocking the interface. If the call is already synchronous there is no need to block the ui, because that's the normal behavior of synchronous calls!
So for me, just removing the "async: false" part made it work.
I hope this helps.
尝试通过将 fadeIn 设置为 0 来消除 blockUI 的异步行为:
Try eliminating the async behavior of blockUI by setting fadeIn to 0: