Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.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
在jQuery表单验证后未发送POST_Jquery_Ajax_Forms_Modal Dialog - Fatal编程技术网

在jQuery表单验证后未发送POST

在jQuery表单验证后未发送POST,jquery,ajax,forms,modal-dialog,Jquery,Ajax,Forms,Modal Dialog,我的表单在引导模式中定义,看起来像: <form class="contact" name="contact" id="contact-form"> <label class="modalLabel" for="name">Name</label><br> <input type="text" name="name" class="input-xlarge" minlength="2" required><br&g

我的表单在引导模式中定义,看起来像:

<form class="contact" name="contact" id="contact-form">
    <label class="modalLabel" for="name">Name</label><br>
    <input type="text" name="name" class="input-xlarge" minlength="2" required><br>
    <label class="modalLabell" for="email">E-mail Adresse</label><br>
    <input type="email" name="email" class="input-xlarge" required><br>
    <label class="modalLabel" for="message">Any message?</label><br>
    <textarea name="message" class="input-xlarge"></textarea>
    <div>
    <input class="btn btn-success" type="submit" value="Absenden" id="submit">
    <a href="#" class="btn btn-warning" data-dismiss="modal">Doch nicht</a>
    </div>
</form>
通过将
$.AJAX
调用放入
click()
函数,我使AJAX在没有验证的情况下工作。在我用jQuery插件添加了验证之后,这篇文章就不再有效了。现在好像已经完成了一个GET,我不知道如何让它工作。

$(form.contact)。ajax({…
可能会抛出错误,因为没有特定于选择器的ajax方法,也没有对象
form.contact
。对于类选择器,它需要在
form.contact
周围加引号

试着换成

$.ajax({...

请查看工作样本:

}))

$('form.contact')
还是
$(form.contact)
$.ajax({...
$("#contact-form").validate({
    submitHandler: function(form) {
        $.ajax({
                    type: "POST",
                    url: "process.php", //process to mail
                    data: $('form.contact').serialize(),
                    success: function(msg){
                        $("#thanks").html(msg) //hide button and show thank you
                        $("#form-content").modal('hide'); //hide popup  
                    },
                    error: function(){
                        alert("Bitte versuchen Sie es nochmal.");
                    }
        });
    }