2012-04-26 39 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);​