成功、失败和提交的Mootools代码

Mootools code for success, failure and submit

本文关键字:Mootools 代码 提交 失败 成功      更新时间:2023-09-26

Mootools验证是否对有类似的过程

SuccessFailureajaxSubmitFile

 $("#rems").validationEngine({
                    ajaxSubmit: true,
                    ajaxSubmitFile: "database/agentpanel/reminder/makerem.php",
                    success : function() { 
                        $.get("database/agentpanel/reminder/loadrem.php", function(html) {
                        $("#rem-scroll").html(html);
                        alert("Reminder Set");
                        $('#rems').find("input[type=text], textarea").val("");
                        $('#rem_confirm').attr('checked', false);
                        });
                    }, 
                    failure : function() { alert("Fill in all the fields with Red Marks"); }
                });

我希望能够在不进入下一页的情况下发送表单,并在successfailure上运行脚本。

您可以将事件函数添加到Mootools表单请求中。

试试这个:

new Form.Request(myForm, myResult, {      
    onSend: function () {  // function to run on send
        alert('Will send now!');
    },
    onFailure: function (){//function to run if failure (fires after onComplete)
        alert('oops...!');
    },
    onComplete: function () {//function to run on send complete
        alert('Submited!');
    }, 
    onSuccess: function () {//function to run on success
        alert('Success!');
    },
    requestOptions: { //etc...

此处演示

值得一读:

  • 表单请求上的Mootools博客
  • Mootools文档(Form.Request)