我想将AJAX实现为联系表单,这是我到目前为止的代码......
$("#contact_form").validate({
meta: "validate",
submitHandler: function (form) {
$('#contact_form').hide();
$('#sucessmessage').append("<h4 class='form_thanks'>Thanks, your email has been sent! We will get back to you as soon as possible</h4>");
return false;
form.submit();
},
/* */
rules: {
name: "required",
lastname: "required",
// simple rule, converted to {required:true}
email: { // compound rule
required: true,
email: true
},
subject: {
required: true,
},
message: {
required: true
}
},
messages: {
name: "Please enter your name.",
lastname: "Please enter your last name.",
email: {
required: "Please enter email.",
email: "Please enter valid email"
},
subject: "Please enter a subject.",
message: "Please enter a message."
},
}); /*========================================*/
});
如何将AJAX jQuery代码实现到此(发布到PHP文件)?
由于
马特
编辑:对于缩进感到抱歉,我比那更整洁,我责怪Dreamweaver! :P答案 0 :(得分:0)
添加此功能:
$('#contact_form').submit(function(){
$.post($(this).attr('action'), $(this).serialize(), function(data){
// whatever you want to do post submit
});
return false;
});
虽然未经过测试..您可能需要在“form.submit”部分添加它,具体取决于代码的其他部分的外观。