如何在通过.ajaxForm()提交表单之前执行某些操作? [英] how to perform some action before submit form via .ajaxForm()?

查看:667
本文介绍了如何在通过.ajaxForm()提交表单之前执行某些操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ajaxForm()框架工作来发送我的数据而不重新加载我的页面。

i am using ajaxForm() frame work to send my data without reloading my page.

    $('#ReplayForm').ajaxForm({ 

      success : function(data){
             alert("Success");
       }   
    });  

现在,我想在提交表格之前检查一些条件,如果条件为假则停止提交否则继续。

now, i want to check some condition before submitting the form and if the condition is false then stop submission else continue.

是否有任何解决方案可以完成这项工作,或者有任何方式购买我可以执行此操作。
提前致谢。

is there any solution to do this work or is there any way buy which i can perform this operation. Thanks in advance.

推荐答案

是的,你肯定可以处理这种情况。你必须先调用beforesubmit方法,看一个例子

Yes, definatly you can handle this situation. you have to call beforesubmit method for this let see one example

$('#ReplayForm').ajaxForm({ 
         beforeSubmit : function(arr, $form, options){
             if("condition is true")
             {
                return true; //it will continue your submission.
             }
             else
             {
                               return false; //ti will stop your submission.
             }

          },
          success : function(data){
              endLoading();
              if(data.result=="success")            
              {
                  showSuccessNotification(data.notification);
              } 
              else
              {
                  showErrorNotification(data.notification);
              }
           }
   });  

这篇关于如何在通过.ajaxForm()提交表单之前执行某些操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆