Hi I\'m using Bootstrap for the first time and I can\'t get my modal form to stay open on clicking the submit button. I\'ve searched SO but all related questions deal with slig
This is how I did in my program, hope it helps.
This is the button which triggers the modal. Here I have disable the keyboard and mouse click outside the modal.
This is the modal div, with a form and a submit button. Replace ...
with your modal content.
Finally the function which triggers when you click submit button. Here event.preventDefault();
will prevent the default action of form submit, so that the modal will remain.
function myFunction() {
$("form").on("submit", function (event) {
event.preventDefault();
$.ajax({
url: "yoururl",
type: "POST",
data: yourData,
success: function (result) {
console.log(result)
}
});
})
}