I can’t seem to get this form to process. When the form submits the page just reloads without making to to the php script.
Here is the html
<form id="defaultForm" method="post" class="defaultForm contact-form">
<div class="form-group">
<label class=" control-label">First Name</label>
<input type="text" class="form-control" name="firstName" />
</div>
<div class="form-group">
<label class="control-label">Last Name</label>
<input type="text" class="form-control" name="lastName" />
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" name="signup" value="Sign up">Submit</button>
</div>
</form>
here is the js:
$('.defaultForm').bootstrapValidator({
message: 'This value is not valid',
live: 'disabled',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
submitHandler: function(validator, form, submitButton) {
//alert("made it to submit handler block!");
$.ajax({
type: "POST",
url: "assets/php/process.php",
data: $('.defaultForm').serialize(),
success: function(msg){
alert("made it to success block!");
//alert(msg);
//document.location.href = 'form.php';
},
error: function(){
alert("We found an error in your data. Please return to home page and try again.");
}
});//close ajax
},
fields: {
firstName: {
validators: {
notEmpty: {
message: 'The first name is required and cannot be empty'
}
}
},
lastName: {
validators: {
notEmpty: {
message: 'The last name is required and cannot be empty'
}
}
},
} // end field
});// bootstrapValidator
I’m not getting any errors in the console.
any ideas?