Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
how to get different data per minutes

I created some progress bars using boostrap 3 which will show some different results every time the page is refreshed. Here is the HTML for my progress bars:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="col-md-5">
  <p>Progress bar1</p>
  <div class="progress progress-striped active">
    <div class="progress-bar"></div>
  </div>
  <p>Progress bar2</p>
  <div class="progress progress-striped active">
    <div class="progress-bar"></div>
  </div>
  <p>Progress bar3</p>
  <div class="progress progress-striped active">
    <div class="progress-bar"></div>
  </div>
</div>

and this is my JavaScript function

$( document ).ready(function() {
    $(".progress-bar").each(function (index ) {
          var percent = Math.floor((Math.random() * 37) + 60);
            $(this).html(percent+"%");
            $(this).animate({width: percent+"%"}, 2500);
            if (percent<79){
              $(this).addClass('progress-bar-danger');
            } else if(parseInt(percent)<89){
              $(this).addClass('progress-bar-warning');
            } else{
              $(this).addClass('progress-bar-success');
            }
    })
});    

So, I want to make the generated data appear every 5 or 10 minutes. not every page is refreshed, how can i do that based on my script ? Thank you

Fiddle Link

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

How about using setInterval? Something like this

$( document ).ready(function() {
$(".progress-bar").each(function (index ) {
   
    setInterval(() => {
       var percent = Math.floor((Math.random() * 37) + 60);
        $(this).html(percent+"%");
        $(this).animate({width: percent+"%"}, 2500);
        if (parseInt(percent)<79){
          $(this).removeClass('progress-bar-danger');
          $(this).removeClass('progress-bar-warning');
          $(this).removeClass('progress-bar-success');
          $(this).addClass('progress-bar-danger');
        } else if(parseInt(percent)<89){
          $(this).removeClass('progress-bar-danger');
          $(this).removeClass('progress-bar-warning');
          $(this).removeClass('progress-bar-success');
          $(this).addClass('progress-bar-warning');
        } else{
          $(this).removeClass('progress-bar-danger');
          $(this).removeClass('progress-bar-warning');
          $(this).removeClass('progress-bar-success');
          $(this).addClass('progress-bar-success');
        }
    }, 300000);
    
    
   })
});    
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda