Hello, how do I create a loading bar does not have to be a progress bar, until I get the return of a function.
$.ajax(settings).done(function (response) {
console.log(response);
}
Hello, how do I create a loading bar does not have to be a progress bar, until I get the return of a function.
$.ajax(settings).done(function (response) {
console.log(response);
}
Use the JqueryBlockUI library, see the implementation below.
$(document).ajaxStart($.blockUI({
message: ' Carregando... '
})).ajaxStop($.unblockUI);
$.ajax({
url: "https://httpbin.org/get",
success: function() {
console.log("Ajax Concluído")
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.js"></script>
Use BeforeSend :
$.ajax({
url: "sua url",
beforeSend: function() {
$('elemento').addClass('.show');//ativa o elemento de carregamento no html
}
})
.done(function( data ) {
$('elemento').addClass('.hidden');//remove o elemento de carregamento no html
});