Automatically download and update Div every 10 seconds using jQuery

I work with a beautiful little jQuery that automatically downloads and updates divs every blah blah. Works fine on all browsers, then I load IE and hit what a surprise no luck !: (

Index.html

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/ libs/jquery/1.3.0/jquery.min.js"></script> <script type="text/javascript"> var auto_refresh = setInterval( function () { $('#load').load('reload.php').fadeIn("slow"); }, 10000); // refresh every 10000 milliseconds <body> <div id="load"> </div> </body> </script> 

reload.php

 <? echo time(); //just a timestamp example.. ?> 

Any ideas guys?

+7
javascript jquery
source share
3 answers

Add a random value at the end of the URL to avoid caching. This should solve your problem. ex: $('#load').load('reload.php?_=' +Math.random()).fadeIn("slow");

+7
source share

Try closing the script tag before the tag tag.

 <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/ libs/jquery/1.3.0/jquery.min.js"></script> <script type="text/javascript"> var auto_refresh = setInterval( function () { $('#load').load('reload.php').fadeIn("slow"); }, 10000); // refresh every 10000 milliseconds </script> </head> <body> <div id="load"> </div> </body> 
+4
source share
  body {text-align:center; background-image: url('http://cdn3.crunchify.com/wp- content/uploads/2013/03/Crunchify.bg_.300.png')} $(document).ready(function() { auto_refresh(); }); function auto_refresh(){ var randomnumber = Math.floor(Math.random() * 100); $('#show').text('I am getting refreshed every 3 seconds..! Random Number ==> '+ randomnumber); } var refreshId = setInterval(auto_refresh, 1000); 
0
source share

All Articles