Refresh div without clicking a button

how to update the div, say, after 10 seconds and execute the run_query () function without pressing a button?

<script src="scripts/ajax.js" type="text/javascript"></script> 



<div id="quote"><strong>Quote of the Day</strong></div>
<div><a style="cursor:pointer" onclick="run_query()">Next quote …</a></div>
+3
source share
2 answers

Use setInterval .

setInterval(function(){run_query();}, 10000);

For bootstrapping, you can do this from server side code.

+11
source
setTimeout("run_query()",10000);
+2
source

Source: https://habr.com/ru/post/1740915/


All Articles