有没有办法使用索引值代替键来循环JSON结果? 我想查看json数据结果并获取发送的密钥和值。
e.g。
$.get('/Home/GetTypes', function (data)
{
$.each(function(index) {
//Just as an example I know this will not work. Thanks
'<a class="p-button" href="/Wizard/Create/" + data[index][value] + " '">' + data[index][key] + '</a>'
}
});
答案 0 :(得分:0)
假设数据是一个字典数组,那你就近了:
$.each(data, function(index, obj) {
// then obj and data[index] both point to the nth entry in data
答案 1 :(得分:0)
for (key in data) {
key = the key name
data[key] = the value
}