我的形式是自舉模式中定義和看起來像後未發送:POST jQuery的表單驗證
<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>
jQuery的對AJAX和驗證:
$("#contact-form").validate({
submitHandler: function(form) {
$(form.contact).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.");
}
});
}
});
我得到了AJAX工作不通過將$.ajax
呼叫放入click()
函數進行驗證。在我用jQuery插件添加驗證後,POST不再工作。目前看起來GET已經完成了,我不知道如何才能正常工作。
它是'$('form.contact')'或'$(form.contact)'? –