使用jquery和ajax在X秒后刷新div

时间:2012-04-26 12:06:04

标签: jquery

我发现this code使用jquery刷新我的div。这工作但我有任何问题。这个插件总是刷新我的div和打印结果。这个坏主意。我需要在div时打印resultresult != 0。在我的ie jquery print 0中的结果div中。这个解决方案的任何方式?感谢

jquery代码:

<script type="text/javascript">
var auto_refresh = setInterval( 
function ()
{
$('#load_tweets').load('record_count.php').fadeIn("slow");
}, 10000);    
<body>
<div id="load_tweets"> </div>

record_count.php(非常简单)result = 0

0

2 个答案:

答案 0 :(得分:0)

var auto_refresh = setInterval(function(){
    $.ajax({
        url:'record_count.php',
        sucsess:function(data){
        if(data!=0)    
            $('#load_tweets').html(data).fadeIn("slow");
        }
    });
}, 10000);​

答案 1 :(得分:0)

试试这个:

var auto_refresh = setInterval(function () {
    $.get('record_count.php', null, function(data) {
        if (data != "0") {
            $('#load_tweets').html(data).fadeIn("slow");
        }
    }, "html")
}, 10000);