Código HTML :
<div class="ajax-loader">
<img src="{{ url('guest/images/ajax-loader.gif') }}" class="img-responsive" />
</div>
Código CSS:
.ajax-loader {
visibility: hidden;
background-color: rgba(255,255,255,0.7);
position: absolute;
z-index: +100 !important;
width: 100%;
height:100%;
}
.ajax-loader img {
position: relative;
top:50%;
left:50%;
}
Código JQUERY:
$.ajax({
type:'POST',
beforeSend: function(){
$('.ajax-loader').css("visibility", "visible");
},
url:'/quantityPlus',
data: {
'productId':p1,
'quantity':p2,
'productPrice':p3},
success:function(data){
$('#'+p1+'value').text(data.newProductQuantity);
$('#'+p1+'amount').text("₹ "+data.productAmount);
$('#totalUnits').text(data.newNoOfUnits);
$('#totalAmount').text("₹ "+data.newTotalAmount);
},
complete: function(){
$('.ajax-loader').css("visibility", "hidden");
}
});
}
document
. Ver stackoverflow.com/questions/2275342/…