The difference between settimeout and setinterval
Code
SetTimeout ("Showresponse (' ${rooturl}index/movie.do ', ' MovieID ')", 400);
SetInterval ("Showresponse (' ${rooturl}index/newwarn.do ', ' Newwarntd ')", 10000);
The Window object has two main timing methods, namely settimeout and setinteval their syntax is basically the same, but the completed function is different.
The SetTimeout method is a timed procedure, that is, what to do after what time. When you're done.
The SetInterval method is to represent the interval for a certain amount of time to perform an operation repeatedly.
SetTimeout ("Todo ()", 1000) means that TODO () is automatically executed once in 1 seconds (1000 milliseconds).
SetInterval ("Todo ()", 1000) refers to the automatic execution of TODO () every 1 seconds. It is a constant interval loop.
If you implement Setinerval functionality with settimeout, you will need to call yourself again and again in the program you are executing. If you want to purge counters that need to be different from the method used, call different cleanup methods:
1) setTimeout (expression, delay time)
At execution time, after the load is delayed for a specified period, the expression is executed once, remembering that the number of times is
Automatic changes implemented with settimeout show the effect of random numbers:
Code
<script>
Window.onload=sett;
function Sett ()
{
Document.body.innerhtml=math.random ();
SetTimeout ("Sett ()", 500);
}
</script>
<body>
</body>
2) setinterval (expression, interaction time)
is not the same, it executes the expression once every specified time from loading
Automatic changes implemented with SetInterval show the effect of random numbers:
Code
<script>
function Sett ()
{
Document.body.innerhtml=math.random ();
}
SetInterval ("Sett ();", 500);
</script>
</script>
<body>
</body>
The difference between settimeout and setinterval