I have this jQuery code:
var now = new Date(Date.now());
console.log("Show LoadingOverlay "+now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds());
$( ".loadingOverlay" ).css("display", "block").animate({"opacity": 0.9});
$.post("myFile.php", {date: true}, function(response) {
var now = new Date(Date.now());
console.log("My Response "+now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds());
});
var now = new Date(Date.now());
console.log("Hide LoadingOverlay "+now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds());
$( ".loadingOverlay" ).animate({"opacity": 0}, 500, function() {$( ".loadingOverlay" ).css("display", "none")});
My problem is, that the loadingOverlay will disappear before the $.post request is finish. Here the console to see that:
Show LoadingOverlay 10:8:16
Hide LoadingOverlay 10:8:16
My Response 10:8:20
It should be:
Show LoadingOverlay 10:8:16
My Response 10:8:16
Hide LoadingOverlay 10:8:20
How can I realize it?