Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajax ve错误地将.validate()包装在单击或提交处理程序中。在您的例子中,您错误地将submit处理程序包装在插件的默认submitHandler中。由于插件的submitHandler回调已经捕获了提交事件,因此附带的submit处理程序是多余的。 $_Ajax_Jquery_Jquery Validate - Fatal编程技术网

Ajax ve错误地将.validate()包装在单击或提交处理程序中。在您的例子中,您错误地将submit处理程序包装在插件的默认submitHandler中。由于插件的submitHandler回调已经捕获了提交事件,因此附带的submit处理程序是多余的。 $

Ajax ve错误地将.validate()包装在单击或提交处理程序中。在您的例子中,您错误地将submit处理程序包装在插件的默认submitHandler中。由于插件的submitHandler回调已经捕获了提交事件,因此附带的submit处理程序是多余的。 $,ajax,jquery,jquery-validate,Ajax,Jquery,Jquery Validate,ve错误地将.validate()包装在单击或提交处理程序中。在您的例子中,您错误地将submit处理程序包装在插件的默认submitHandler中。由于插件的submitHandler回调已经捕获了提交事件,因此附带的submit处理程序是多余的。 $("#my-form").validate({ submitHandler: function(form) { **js from other page** } }); $("#add-form").validate({

ve错误地将
.validate()
包装在
单击
提交
处理程序中。在您的例子中,您错误地将
submit
处理程序包装在插件的默认
submitHandler
中。由于插件的
submitHandler
回调已经捕获了提交事件,因此附带的
submit
处理程序是多余的。
$("#my-form").validate({
  submitHandler: function(form) {
    **js from other page**
  }
});
$("#add-form").validate({
    submitHandler: function (form) {
        // setup some local variables
        var $form = $(form);
        // let's select and cache all the fields
        var $inputs = $form.find("input, select, button, textarea");
        // serialize the data in the form
        var serializedData = $form.serialize();

        // let's disable the inputs for the duration of the ajax request
        $inputs.prop("disabled", true);

        // fire off the request to /form.php

        request = $.ajax({
            url: "forms.php",
            type: "post",
            data: serializedData
        });

        // callback handler that will be called on success
        request.done(function (response, textStatus, jqXHR) {
            // log a message to the console
            console.log("Hooray, it worked!");
            alert("success awesome");
            $('#add--response').html('<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>Well done!</strong> You successfully read this important alert message.</div>');
        });

        // callback handler that will be called on failure
        request.fail(function (jqXHR, textStatus, errorThrown) {
            // log the error to the console
            console.error(
                "The following error occured: " + textStatus, errorThrown);
        });

        // callback handler that will be called regardless
        // if the request failed or succeeded
        request.always(function () {
            // reenable the inputs
            $inputs.prop("disabled", false);
        });

    }
});
var $form = $(this);
var $form = $(form);
$("#add-form").validate({
    submitHandler: function (form) {
        var request;
        // bind to the submit event of our form



        // let's select and cache all the fields
        var $inputs = $(form).find("input, select, button, textarea");
        // serialize the data in the form
        var serializedData = $(form).serialize();

        // let's disable the inputs for the duration of the ajax request
        $inputs.prop("disabled", true);

        // fire off the request to /form.php

        request = $.ajax({
                url: "forms.php",
                type: "post",
                data: serializedData
        });

        // callback handler that will be called on success
        request.done(function (response, textStatus, jqXHR) {
                // log a message to the console
                console.log("Hooray, it worked!");
                alert("success awesome");
                $('#add--response').html('<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>Well done!</strong> You successfully read this important alert message.</div>');
        });

        // callback handler that will be called on failure
        request.fail(function (jqXHR, textStatus, errorThrown) {
                // log the error to the console
                console.error(
                    "The following error occured: " + textStatus, errorThrown);
        });

            // callback handler that will be called regardless
            // if the request failed or succeeded
        request.always(function () {
                // reenable the inputs
                $inputs.prop("disabled", false);
        });            

    }
});