jQuery getJSON未定义错误

via*_*ath 5 javascript jquery json

好吧,所以我做了一些搜索,没有运气.我希望这里有人能指出我正确的方向.我有一个我正在使用的JSON提要,它应该输出各种数据.目前,它只发送回所有变量的"UNDEFINED"响应.这是我正在使用的JS:

$("#loaduserdata").click(function(){
$("#userdata tbody").html("");
    $.getJSON("trendFetch", function(data){
            $.each(data.list, function(i, data){
                var jsondata = data.action;
                console.log (jsondata);
            });
     }
);
Run Code Online (Sandbox Code Playgroud)

我不确定问题出在哪里,因为控制台没有给我任何错误或任何理由认为JSON格式不正确:http://i.imgur.com/ySpdR.png

无论它值多少,这里是我用来生成JSON的代码 - 也许这个问题就是这个问题?

$curl = curl_init();
$url = 'http://api.site.com';

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => $url
));

$resp = curl_exec($curl);

if($resp){
    echo $resp;
    header("Content-Type: application/json", true);
}
else {
    echo 'Error - no response!';
}

curl_close($curl);  
Run Code Online (Sandbox Code Playgroud)

编辑 - 包括JSON输出:

{
"status": "ok",
"list": {
    "list_id": "2gz",
    "title": "Test List",
    "description": "description text...",
    "image": [
        "http://t2.gstatic.com/images?q=tbn:ANd9GcTz6_4aV6oHsI2kgJRRoSFCTWbew5ChTeBrAmXYh4Gez2J7usm8nwMOsA",
        "http://cdn.list.ly/logos/default-list-image.png"
    ],
    "views": 0,
    "item_count": 1,
    "curator_count": 1,
    "follower_count": 1,
    "listly_url": "http://api.list.ly/list/2gz-test-list",
    "items": [
        {
            "item": {
                "name": "Link 1",
                "image": "http://t2.gstatic.com/images?q=tbn:ANd9GcTz6_4aV6oHsI2kgJRRoSFCTWbew5ChTeBrAmXYh4Gez2J7usm8nwMOsA",
                "note": null,
                "url": null,
                "likes": 0,
                "dislikes": 0
            }
        }
    ],
    "suggested_items": []
}
}
Run Code Online (Sandbox Code Playgroud)

Mus*_*usa 3

在任何输出之前设置标题

header("Content-Type: application/json", true);
echo $resp;
Run Code Online (Sandbox Code Playgroud)