So I have a modal which has this form. There's a button on the form which says " Save & Exit ". Hitting it, the data is getting saved into the DB correctly via ajax but how do I close the modal simultaneously and refresh the parent page?
Code to open modal
<button type="button" class="float-right" data-toggle="modal" data-target="#attribute_contact">
<i class="fa fa-pencil"></i>
</button>
Modal
<div class="modal fade" id="attribute_contact" role="dialog">
<div class="modal-dialog modal-lg">
Save & Close Button :-
<input type="submit" name="submit" value="Save & Close" id="submit_button" class="btn btn-success">
AJAX
$("#left_side_profile").submit(function(e){
e.preventDefault();
// alert("submitted");
$.ajax({
type: 'POST',
url: 'ajax.php',
data: $('#left_side_profile').serialize(),
success: function (data) {
window.location.href = "editprofile.php";
}
});
});
Any help would be greatly appreciated.
In the success function first close the modal
$("#attribute_contact").modal('hide');
then reload the page
location.reload();
success: function (data) {
$("#attribute_contact").modal('hide');
location.reload();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.