0

Jqueryを使用してjson形式から「customers_firstname」のみを抽出するにはどうすればよいですか?

<?php echo json_encode($users) ?>

出力

[{"Customer":{"id":"13","customers_gender":"M","resumetest":"a15ff2aa27d616636b5bc30fac4dba38733f4e5f","created":"2013-01-29 13:49:06","modified":"2013-03-14 11:50:18","customers_firstname":"Gerald","customers_lastname":"Russ"}},{"Customer":{"id":"14","customers_gender":"F","resumetest":null,"created":"2013-01-29 15:41:23","modified":"2013-02-14 15:08:42","customers_firstname":"Jim","customers_lastname":"Carrie"}}] 
4

2 に答える 2

1

これを試して :

デモ

HTML

<ul id="nameList">
</ul>

JS

var customers = [{"Customer":{"id":"13","customers_gender":"M","resumetest":"a15ff2aa27d616636b5bc30fac4dba38733f4e5f","created":"2013-01-29 13:49:06","modified":"2013-03-14 11:50:18","customers_firstname":"Gerald","customers_lastname":"Russ"}},{"Customer":{"id":"14","customers_gender":"F","resumetest":null,"created":"2013-01-29 15:41:23","modified":"2013-02-14 15:08:42","customers_firstname":"Jim","customers_lastname":"Carrie"}}];

$.each(customers, function (index, item) {

        $("#nameList").append("<li>" + item.Customer.customers_firstname + "</li>");
    });
于 2013-03-21T03:16:25.143 に答える
0

以下のコードを AJAX 成功ブロックで使用できます

$.each(json_data, function (index, customer){//here json_data is success response from the Server
if (customer){
console.log(customer["customers_firstname"];
}
})
于 2013-03-21T03:11:49.957 に答える