I want to close the bootstrap 5 modal before sending ajax. For this, I used the following code, but Ajax runs first then the medal is closed.
jQuery.ajax({
async: false,
beforestart: function () {
$("#freeModal").modal('hide');
},
url: '/url',
})
And I don’t want to use the following codes:
$("#myModal").modal('hide')
$("#myModal").on('hidden.bs.modal', function(){
jQuery.ajax({
async: false,
url: '/url',
})
});
Is there a way to close the medal first and then send Ajax?