Pop up a message while not bringing the database results

Asked

Viewed 351 times

2

Colleagues,

Unfortunately I have no code for this doubt, because I do not know much jquery, but I have a page where I bring the results of a mysql database, but in some cases the result takes a little to appear. How I would make a message appear (wait, data being processed) or loading gif eqto the results do not appear?

I’m bringing the results up as follows:

Page view-users.php

<html>
.....
<h2>Relação dos usuários cadastrados</h2>
<?php echo $metodos->visualizarUsuarios(); ?>
.....
</html>

Within $methods->visualise() I bring the results of a query procedural using mysqli_().

public function visualizarUsuarios(){
 ....
  $sqlVisualizar = mysqli_query($this->conexao,"SELECT * FROM visualizar_usuarios");

  while($jmVisualizar = mysqli_fetch_object($sqlVisualizar)){
    // Resultados  
  }  

}
  • You are loading the data via Ajax?

  • Hello Arthur, we are not using charging via Ajax.

1 answer

3

Just have the message displayed before going to make the request to the database and then you hide the message when you return the data (success or error response), example below is via ajax. Post as you are making these requisitions in the bank so I can help you better.

function processar(){
  $('#aguarde').show();
  $.ajax( 'https://httpbin.org/delay/2' )
    .done(function() {
      alert('Terminou o processamento');
      $('#aguarde').hide();
    })
    .fail(function() {
      alert('Terminou o processamento - ERRO');
      $('#aguarde').hide();
    });
  
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<button onclick="processar()">Processar</button>
<div id="aguarde" style="display:none">Aguarde, estamos processando</div>

  • Hello Hugo. I changed my post including the requested information.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.