I want to use submit event instead of click I am trying to submit a simple form the click event works in my console but the submit instead, not firing. i submitted the html part
$('#signupform').click(function(e){
//prevent default php processing
e.preventDefault();
//collect user inputs
var datatopost= $(this).serializeArray();
console.log(datatopost);
//send them to signup.php using AJAX
$.ajax({
url: "signup.php",
type: "POST",
data: datatopost,
success: function(data){
if(data){
$("#signupmessage").html(data);
}
},
error: function(){
$("#signupmessage").html("<div class='alert alert-danger'>There was an error enter code here the Ajax Call, Please try again later.</div>");
}
})
})
click
event on the form when it should be looking for asubmit
event. Or, you should be looking for theclick
event on thesubmit
button. – Tangentially Perpendicular Jan 13 at 21:36