Load script every X seconds

0

I have an Odometer in JS that is fed by a notepad, so I needed to load load.txt every 5 seconds or so ...

I tried to use setTime () but it did not work!

Follow the part you would like to run every 5 seconds ...

$("odometer").load("counter.txt");

Any ideas?

    
asked by anonymous 14.11.2018 / 23:34

1 answer

1

If you expect a recursive behavior, you should use setInterval()

function carregar()
{
  ///$("odometer").load("counter.txt");
  console.log('olar');
}

setInterval(carregar,5000);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    
14.11.2018 / 23:42