Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 返回带有jQuery.post的JSON结果为;“未定义”;_Php_Jquery_Ajax_Json_Post - Fatal编程技术网

Php 返回带有jQuery.post的JSON结果为;“未定义”;

Php 返回带有jQuery.post的JSON结果为;“未定义”;,php,jquery,ajax,json,post,Php,Jquery,Ajax,Json,Post,在php中: 结果如下: return json_encode($output); 以下是jQuery: [ { "u_s_user": "UserName", "u_s_first_name": "First", "u_s_last_name": "Last", "u_s_email":"me@domain.org" } ] 例如,当我发出警报(data.u_s_email)时,我会得到未定义的 我在这里做错了

在php中:

结果如下:

return json_encode($output);
以下是jQuery:

[
    {
        "u_s_user": "UserName",
        "u_s_first_name": "First",
        "u_s_last_name": "Last",
        "u_s_email":"me@domain.org"
    }
]
例如,当我发出
警报(data.u_s_email)
时,我会得到
未定义的


我在这里做错了什么?

我相信你想要的是
数据[0]。u\u s\u user
而不是
数据。u\u s\u user


(类似地,在所有其他键前加上
数据[0]
,而不仅仅是
数据

我相信您想要
数据[0]。u___用户
而不是
数据。u___用户


(类似地,在所有其他键前加上
数据[0]
,而不仅仅是
数据

对于这个请求,你在网络选项卡上看到了什么?@科学家我的网络选项卡上显示了代码200,上面的响应完全是JSON。对于这个请求,你在网络选项卡上看到了什么?@科学家我的网络选项卡上显示了代码200,上面的响应完全是JSON。我的想法是一样的:)就是这样!谢谢标记正确。我在jQuery中没有看到这一点。docsi的想法是一样的:)就是这样!谢谢标记正确。我在jQuery.docs中没有看到这一点
function PopulateUserFieldsToEdit() {
    var user_num = $("#choose_user_to_edit").val();
    $.post( url, {   
        _get_user_fields : 1, 
               _user_num : user_num, },
        function(data) {
            alert(data.u_s_first_name);
            $("#user_username").val(data.u_s_user);
            $("#user_firstname").val(data.u_s_first_name);
            $("#user_lastname").val(data.u_s_last_name);
            $("#user_email").val(data.u_s_email);
        }, "json" );
}