Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto Load and Refresh Div every 10 Seconds with jQuery

I'm working with a nice little Jquery that auto loads and refreshes a div every bla bla Seconds. Works perfectly on all browsers then I load up IE and bang 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?

like image 997
Webby Avatar asked Jun 25 '10 20:06

Webby


2 Answers

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

like image 87
Teja Kantamneni Avatar answered Sep 22 '22 19:09

Teja Kantamneni


Try closing your script tag before having your body 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>
like image 37
Catfish Avatar answered Sep 22 '22 19:09

Catfish