I have an ajax request, where I just sent some data and before that I have an animation, the problem is that before doing the ajax I want a load effect but it seems that as it is an asynchronous request it is executed first and finally it leaves the animation so that for a short period of time it would seem like nothing was running.
I've already tried with the beforeSend and it does not work
Thank you very much, this is the code
function queryEmails (callback) {
$("#loading").modal('show');
var formSerialize = $("form").serialize();
var rows = $('#QueryEmailsTable tr').length;
jQuery.ajax({
url: '/SupervisorManager/FindEmails',
dataType: 'json',
data: formSerialize,
async: false,
type: 'POST',
beforeSend: function ()
{
document.getElementById("QueryEmailsTable").innerHTML = "";
},
success: function (result)
{
callback(result, rows);
},
complete: function ()
{
setTimeout(function ()
{
$('#loading').modal('hide');
document.getElementById("dataInfo").style.display = "block";
}, 1000);
onComplete();
},
error: function ()
{
addFailureMessage("Error, don't load emails campaign info");
}
});
}