jquery-loadmask:我应该在哪里调用unmask()?
我想使用 jquery-loadmask 插件在传输表单数据时屏蔽表单(我使用 AJAX 来调用将数据存储在数据库中的操作)。
为了屏蔽我正在使用的表单:
$('#form').submit(function () {
form_data = $.param($(this).serializeArray());
$.ajax({
url: "<?php echo url_for('profile/index') ?>",
type: "POST",
data: form_data,
});
$("form").mask("Loading...");
return false;
});
但是我应该在哪里调用 unmask() ?
问候
哈维
i want to use jquery-loadmask plugin to mask a form while the form data is transmited (I have used AJAX to call the action that store the data in the db).
To mask the form i'm using this:
$('#form').submit(function () {
form_data = $.param($(this).serializeArray());
$.ajax({
url: "<?php echo url_for('profile/index') ?>",
type: "POST",
data: form_data,
});
$("form").mask("Loading...");
return false;
});
But where should i call unmask() ?
Regards
Javi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该在
success
回调中取消屏蔽(当服务器返回数据时),如下所示:或者,较短的
$.post()
格式:You should unmask in your
success
callback (when the server comes back with data), like this:Or, the shorter
$.post()
format:只需添加成功或错误处理程序:
success: function(data, textStatus, XMLHttpRequest) { $("form").unmask(); }
Just add a success or error handler:
success: function(data, textStatus, XMLHttpRequest) { $("form").unmask(); }