Update multiple Ivs on one page

Asked

Viewed 98 times

0

I have a page where I need to update some divs with information coming from the bank. With this I am doing this way:

<div id='diva'>conteúdo a</div>
<div id='divb'>conteúdo b</div>
<div id='divc'>conteúdo c</div>

And so on. In jQuery:

setInterval(function() {
  $("#diva").load(location.href+" #diva");
  $("#divb").load(location.href+" #divb");
  $("#divc").load(location.href+" #divc");
}, 1000);

Only I realized that by staying a few minutes on the same page, the page flashes and then the data disappears, coming right back. Would have some way of minimizing that impact?

  • The data appears and then they disappear and appear again, or they are only shown later?

  • appear and vanish... then appear,.... then the page stops blinking and flashes again....

  • At the end of the setInterval (inside it yet), add console.log("Load"). See how often the message appears on the console when the page loads.

  • I put before or after the 1000?

  • Before, "(inside it still)".

  • I put it this way: console.log("Load") }, 1000);

  • appears every 1 sec..

  • I believe if I change it to 10 seconds, it’ll lessen that impact, right? about the structure of jquery, it is correct to put several Divs the way it was placed?

  • And do you need to change/load all these Ivs every second? (1000 ms)

  • It’s... a fault of mine... but I corrected and put 15 seconds... the initial idea was for each message that appeared, automatically updated. 15 seconds I believe it’s good, but if I’m wrong, I’m happy to be corrected :)

Show 5 more comments
No answers

Browser other questions tagged

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