1.检查下文件目录是不是对的
2.直接打开count_index.php看输出结果是什么样的

解决方案 »

  1.   

    我已经打开了。输出的是 {"bmzs":49} 应该是json格式啊!可是不知道为什么就是不行
      

  2.   

    传回来的应该是字符串不是JSON对象, 这样试一下function update_page(strData){ 
        eval("var data=" + strData);
        $("#date").html(data.bmzs); 
    alert('dd'); 

      

  3.   

    $(document).ready(function(){  
       window.setInterval(function () {
                    GetData()}, 4000);
     }); function GetData()//取值方法,参数i表示页数
             {
       $.getJSON("ajax/count_index.php","",update_page);
             }
     function update_page(strdata){
     eval('var data=' + strdata + ';'); 
    $("#date").html(data['bmzs']);
     }
    <div id="date"> </div> 
    -------------count_index.php---------------- 
    $arraye=array("bmzs"=>rand(38, 49)); 
    print_r (json_encode($arraye)); 
    还是不对啊!运行后系统提示 缺少],这又是怎么回事啊!怎么这么麻烦啊
      

  4.   

    像返回某种格式的数据,在ASP/JAVA/PHP里都有类似的写法:
    以下是XML的
    response.setContentType("text/xml");
    我想JSON应该也要设置一下返回的文档格式类型的吧,你找一下
    给你两个参考一下:
    http://www.th7.cn/Article/bc/ph/200901/344806.html
    http://bbs.phpchina.com/redirect.php?tid=97640&goto=lastpost