我收到 JSON 回复,如下所示:
[{
"order_id": "12",
"customer": "user user",
"status": "Pending",
"date_added": "02\/09\/2012",
"total": "$500.00",
"action": [{
"text": "View",
"href": "http:\/\/localhost\/oc\/admin\/index.php?route=sale\/order\/info&token=92a80574e5fcbf3e2d021404cfaae1a4&order_id=12"
}]
}]
看看动作键,它的值又是一个数组。我正在尝试通过以下代码获取操作键值,但它对我显示未定义
function (data) {
if (data) {
for (var i = 0; i < data.length; i++) {
$('div.dashboard-content table.list tbody tr:first').before(
'<tr id="' +
data[i]['order_id'] +
'"><td class="right">' +
data[i]['order_id'] +
'</td><td class="left">' +
data[i]['customer'] +
'</td><td class="left">' +
data[i]['status'] +
'</td><td class="left">' +
data[i]['date_added'] +
'</td><td class="right">' +
data[i]['total'] +
'</td><td class="right"> [<a href="' +
data[i]['action']['href'] + '">' +
data[i]['action']['text'] +
'</a>]</td></tr>'
);
}
}
}
有人可以帮助我吗?提前致谢。