[英]Loop through data in a JSONResult
有没有一种方法可以使用索引值而不是键来遍历JSON结果? 我想浏览json数据结果并获取发送过来的键和值。
例如
$.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>'
}
});
假设数据是一个字典数组,那么您将很接近:
$.each(data, function(index, obj) {
// then obj and data[index] both point to the nth entry in data
for (key in data) {
key = the key name
data[key] = the value
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.