I have a js function in my .cshtlm form, witch I call it from a button.
My function hide the button, show a progress bar, call 2 ajax, hide the progress bar and finally shows a message.
JS Function code
var CustomsBook = function () {
var month = $("#month").val();
var message = "";
var errorMessage = "";
$("#btn").hide();
$("#prcs").show();
$("#progressbar").show();
$("#successMessage").empty().hide();
$("#dangerMessage").empty().hide();
$.ajax({
async: false,
url: "/Logistics/jCustomsBookHQ",
type: "POST",
data: { month: month },
success: function (HQresponse) {
if (HQresponse.success) { message += HQresponse.message; }
else { errorMessage += HQresponse.message; }
}
});
$.ajax({
async: false,
url: "/Logistics/jCustomsBookBr",
type: "POST",
data: { month: month },
success: function (BRresponse) {
if (BRresponse.success) {
if (message.length > 0) { message += " <br> "; }
message += BRresponse.message;
}
else {
if (errorMessage.length > 0) { errorMessage += " <br> "; }
errorMessage += BRresponse.message;
}
}
});
$("#prcs").hide();
$("#progressbar").hide();
$("#successMessage").html(message);
if (message.length > 0) {
$("#successMessage").show();
}
$("#dangerMessage").html(errorMessage);
if (errorMessage.length > 0) {
$("#dangerMessage").show();
}
}
When I push the button to call the function the $("#prcs").show();
and $("#progressbar").show();
doesn't work. If I use a debugger and run step by step the code the proggress bar shows up and hide after the ajaxs end.
I try to write 2 different function one for every ajax and replace the ajax code with call to the functions with the same result.
Do I miss something?
Thanks in advance for every help.