Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

div refresh without click of the button

how do i make the div refresh, say after 10 secs and execute the run_query() function without clicking on the 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>
like image 991
input Avatar asked Dec 12 '22 22:12

input


2 Answers

Use setInterval function.

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

For the initial load you can do that from the server side code.

like image 76
rahul Avatar answered Jan 03 '23 03:01

rahul


setTimeout("run_query()",10000);
like image 22
slier Avatar answered Jan 03 '23 01:01

slier