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

时间:2013-09-03 22:06:27

标签: javascript ajax forms mootools

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上运行脚本。

1 个答案:

答案 0 :(得分:1)

您可以将事件功能添加到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...

演示here

值得一读: