Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda