i want to insert data without page reload. here is the html form i have used. taskinsert.php is the php file which i have used.
`<form class="form-horizontal" id="form_post" enctype="multipart/form-data">
<div class="row">
<div class="form-group col-md-12">
<label class="col-sm-2" for="uploadedimage">Image :</label>
<div class="col-sm-7">
<input type="file" class="btn btn-primary" name="uploadedimage" id="uploadedimage">
</div> <div class="col-sm-3"></div>
</div>
<div class="form-group col-md-12">
<label class="col-sm-2" for="email">Email :</label>
<div class="col-sm-7">
<input type="text" class="" name="email" id="email">
</div> <div class="col-sm-3"></div>
</div>
<div class="form-group col-md-12">
<label class="col-sm-2" for="phone">Phone :</label>
<div class="col-sm-7">
<input type="text" class="" name="phone" id="phone">
</div> <div class="col-sm-3"></div>
</div>
<div class="form-group col-md-12">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" class="btn btn-success" name="gk" id="gk" value="submit">
</div>
</div>
</div>
</form>`
how to insert data in database without page reload? I have tried this , any ideas? below is the script i have used. I think the problem is in the script.
`<script>
$("#gk").click(function(){
$("form#form_post").submit(function(event){
event.preventDefault();
var formData = new FormData($(this)[0]);
$.ajax({
url: 'taskinsert.php',
type: 'POST',
contentType: false,
processData: false,
success: function (response) {
$('#success').html(response);
var form=document.getElementById('form_post').reset();
return false;
}
});
});
});
</script>`