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

198
Vistas
When I use load my flash message doesn't disappear

I am trying to make a "widget" inside a home screen. And this "widget" will display messages depending on the user's actions with it.

I don't want to reload the entire page, since there may be another "widget" with user information that I haven't finished filling in. So I've been getting by doing a load.

$('#user_credit .card-body #message').load(' #user_credit .card-body #message');

Now with this code the flash appears, either that it has been done correctly or if there has been an error.

The problem is that this message does not disappear automatically.

I've gotten it to go away using a timer in JS.

setTimeout(() => {  $("#message").attr('style', 'display:none') }, 2000);

But now it doesn't show up again. So I had to add another timer.

setTimeout(() => {  $("#message").attr('style', 'display:block') }, 100);

In the end the code is like this:

$('#user_credit .card-body #message').load(' #user_credit .card-body #message');
setTimeout(() => {  $("#message").attr('style', 'display:block') }, 100);
setTimeout(() => {  $("#message").attr('style', 'display:none') }, 2000);

With all this it works correctly. But my question is, if reloading manually without all that code works, that is, it appears and disappears, how can I make it appear and disappear without using the timers.

Thank you very much in advance.

Excuse my English I'm using google translator


If I use reload works, but this reload all the page.

location.reload();
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

use $(document).ready();:

$(document).ready(function(){
 $("#message").attr('style', 'display:block');
});

it will set display:block for message whenever document loaded completely.

about 4 years ago · Juan Pablo Isaza 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