Upload Bar

1

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);
}
    
asked by anonymous 29.10.2018 / 15:53

2 answers

1

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>
    
29.10.2018 / 19:18
0

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
      });
    
29.10.2018 / 19:22