2012-04-26 67 views
0

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

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(很简单),结果为0

0 
+0

仅供参考:我删除PHP文件中多余的代码,你实际上可以使用一个静态文件,这就是为什么我删除标签以及。 – hakre 2012-04-26 12:08:54

回答

0

试试这个:

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