jquery-loadmask:我应该在哪里调用unmask()?

发布于 2024-10-03 05:57:56 字数 585 浏览 8 评论 0原文

我想使用 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技术交流群

发布评论

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

评论(2

七婞 2024-10-10 05:57:56

您应该在 success 回调中取消屏蔽(当服务器返回数据时),如下所示:

$.ajax({
   url: "<?php echo url_for('profile/index') ?>",
   type: "POST",
   data: form_data,
   success: function() { $("form").unmask(); }
});

或者,较短的 $.post() 格式:

$.post("<?php echo url_for('profile/index') ?>", form_data, function() {
  $("form").unmask();
});

You should unmask in your success callback (when the server comes back with data), like this:

$.ajax({
   url: "<?php echo url_for('profile/index') ?>",
   type: "POST",
   data: form_data,
   success: function() { $("form").unmask(); }
});

Or, the shorter $.post() format:

$.post("<?php echo url_for('profile/index') ?>", form_data, function() {
  $("form").unmask();
});
吃兔兔 2024-10-10 05:57:56

只需添加成功或错误处理程序:

$.ajax({

           url: "<?php echo url_for('profile/index') ?>",

           type: "POST",

           data: form_data,

success: function(data, textStatus, XMLHttpRequest) { $("form").unmask(); }

       });

Just add a success or error handler:

$.ajax({

           url: "<?php echo url_for('profile/index') ?>",

           type: "POST",

           data: form_data,

success: function(data, textStatus, XMLHttpRequest) { $("form").unmask(); }

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