Validate- Ajax Submit is actually refreshing page
Hi,
I love .validate() I(if that is the proper way to refer to it). It really is very, very good. Trying to move all my forms to Ajax. I get the form to submit, but for some reason, it won't submit properly . It actually refreshes the page.
IF i remove the validate functions, and use just the " $(form).ajaxSubmit({" everything works fine.
I have also tried $.ajax, and achieved the same result.
I am sure it is something simple, but help would be appreciated.
- $("#contactForm").validate({
rules: {
name: "required",
phone: "required",
recaptcha_response_field: "required",
email: {
required: true,
email: true
}
},// end rules
messages: {
name: "Please enter your name",
recaptcha_response_field: "Please Complete",
phone: "Please enter Your Phone Number",
email: "Please enter a valid email address",
},// end messages
submitHandler: function(form) {
$(form).ajaxSubmit({
url: 'ppmailcontactajax.php', // form action url
type: 'POST', // form submit method get/post
dataType: 'html', // request type html/json/xml
data: form.serialize(), // serialize form data
beforeSend: function() {
message.fadeOut();
submitButton.val('Sending....');
},
success: function(data) {
var response = $.parseJSON(data);
message.html(response.message).fadeIn();
form.trigger('reset'); // reset form
submitButton.val('Send Email');
},
error: function(e) {
console.log(e)
}
});
}// end submit handler
}); //end validate