I am working on an AJAX call which is updating records and fetching the latest records as well and then loading multiple DIV, the process of updating the fetching is working perfectly fine except that I am displaying the loading gif while this process is taking place. The gif appears but then disappears too quick. I am wondering how to keep this loading giv on screen till the entire process is complete.
This is my AJAX call
<script>
function update() {
$.ajax({
type: "POST",
url: "abc.php",
data: $("#pay-form").serialize(),
beforeSend: function () {
$('#dvloader').show();
},
success: function (html) {
$('#income-expense-div').load('dashboard-sidebar.php');
$('#pay-div').load('dashboard-pay.php');
$('#assets-div').load('dashboard-assets.php');
$('#liabilities-div').load('dashboard-liabilities.php');
$('#dvloader').hide(500);
}
});
}
</script>
This is my loading div that appears with gif image
<div style="display: none" class="loading_gif" id="dvloader">
<p><img style="margin-top: 20%;margin-left: 40%;" src="assets/img/loading.gif"></p>
</div>
This is the CSS of loading div
.loading_gif{
margin: auto;
position: fixed;
z-index: 1000;
cursor: wait;
top: 0;
left: 0;
background: #fff;
height: 100%;
width: 100%;
opacity: 0.8;
}
I will really appreciate any help here