Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!