I have this code: <script type="text/javascript"> var auto_refresh = setInterval( function () { $('#load_news').load('ajax/news.php').fadeIn("slow"); }, 10000); // refresh every 10000 milliseconds </script> Code (markup): But I want it so when one clicks on the page content is already there and then it refreshes. Right now it takes about 15 seconds for the content to show, so having it there as soon as the page loads then it can refresh the news file would be great. Any idea how to do that?
yea, simple; <script type="text/javascript"> function doLoad () { $('#load_news').load('ajax/news.php').fadeIn("slow"); } doLoad(); var auto_refresh = setInterval( function () { doLoad(); }, 10000); // refresh every 10000 milliseconds </script>
<script type="text/javascript"> function doLoad () { $('#load_news').load('ajax/news.php').fadeIn("slow"); } doLoad(); var auto_refresh = setInterval(doLoad, 10000); // refresh every 10000 milliseconds </script> Code (markup):