开发者

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开发者_StackOverflow社区>

reload.php

<?

echo time(); //just a timestamp example..

?>

Any ideas guys?


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");


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>


  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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜