0
$.post('ol_st_checker.php',function(d){              //this method is going to check who ever is online
    $.each(d.uinfo,function(index,value) {
        alert(index+'='+value);
       /*$.each(this,function(index, element) {
            alert(index+'='+element);
        });*/
    });
},'json');},

使用 PHP json_encode 发送到浏览器的数据如下所示:

[{"uinfo":{"0":"1","status":"1","1":"1001","user_id":"1001","2":"2013-05-09 22:24:10","last_update":"2013-05-09 22:24:10"}}]

在警报框中,我得到“未定义”,但是当我尝试在发布功能之后显示警报时,我得到了上述输出。

4

1 回答 1

0

试试这 d是一个数组。d[0].uinfo是您尝试访问的对象。

$.post('ol_st_checker.php',function(d){              //this method is going to check who ever is online
    $.each(d[0].uinfo,function(index,value) {
        alert(index+'='+value);
       /*$.each(this,function(index, element) {
            alert(index+'='+element);
        });*/
    });
    },'json');},
于 2013-05-09T17:05:17.953 回答