代码是这样的! 
----------------index.php----------------- 
$(document).ready(function(){  
  window.setTimeout(function () { 
                GetData()}, 4000); 
}); 
function GetData(){//取值方法,参数i表示页数 
  $.getJSON("ajax/count_index.php",update_page); 

function update_page(data){ 
    $("#date").html(data.bmzs); 
alert('dd'); 
} <div id="date"> </div> 
-------------count_index.php---------------- 
$arraye=array("bmzs"=>rand(38, 49)); 
print_r (json_encode($arraye)); 
-------------------------------------------- 
不知为何,总是取不到返回的json数据,而且也不能定时刷新,数据!郁闷之极! 

解决方案 »

  1.   

    window.setInterval(function () {
                    GetData()}, 4000); jQuery.getJSON("ajax/count_index.php","",update_page)
      

  2.   

    楼主请用setInterval方法, 这是设定时间反复调用函数的方法;setTimeOut()实际上是个延时方法, 设定在多长时间后执行 一次 方法
      

  3.   

    setTimeOut 只执行一次的
    setInterval 间隔时间调用..
      

  4.   

    $(document).ready(function () {
        $("#date").text((new Date()).toString());
        window.setTimeout(function () {
        location.reload();
        }, 1000);
    });setTimeout 也可以实现,不过要循环调用自己。不过推荐用 setInterval