I have a button which opens a modal but I have prevented the modal close by clicking background or ESC key.
My button looks like this:
You can try something like below. Untested but you'll get the idea.
$.ajax({ url: 'yourscript.php', data: $('form#yourForm').serialize(), type: 'post' }).done(function(response) { // trigger modal closing here since ajax is complete. });