简体   繁体   中英

SVG/D3 - JSON reload every 10 seconds

How do I program a D3/json/ajax query which invites new data every 10 seconds.

Here is my first approach for a solution, I think it is not good:

setInterval(function() {
  d3.json("http://1.....", function(json) {
  ....
  })

}, 1000); 

As it is right or is there a better approach?

Many thanks

For timed execution of a method setInterval is your best option setTimeout could be used but setInterval for this purpose would be better. I would however ensure that your first ajax call has completed before triggering the function again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM