Stumped; I have created a form with data submitted through ajax everything seems to work perfectly except.... After I submited the next submit adds two forms of the data and then three and then four. Your help would be appreciated as always thanks.... learning from you
<form name="form_page_2" id="form_page_2" method="POST" enctype="multipart/form-data">
<div>
<label class="form_0">Name</label>
<input type="text" id="route_name" name="route_name" class="input" value="">
<label class="red" id="lable_route_name"></label>
</div>
<a href="javascript:insertForm()">insert</a>
then insert form is :
function insertForm (form){
form.submit(function(e){
var $this=$(this);
var postData;
postData = $this.serializeArray();
var inputResult=checkFormInputs(form);
if(checkAllInputs(inputResult)==false){
return false;
};
$.ajax({
url : 'post_server.php',
type: "POST",
data : postData,
success:function(dataPost, textStatus, jqXHR) {
console.log(dataPost);
},
error: function(jqXHR, textStatus, errorThrown) {
//if fails
}
});
e.preventDefault(); //STOP default action
});
form.submit();
}
the checkAllInputs returns true/false if all inputs are correctly checked even when this returns false the next submit will add "two" submits??
Console returning print_r
Array ( [route_name] => this is a test ) Array ( [route_name] => this is a test )
two submits?