Is there a way to loop through JSON results us开发者_StackOverflow社区ing an index value instead of the key? I would like to look through the json data result and grab the key and value that was sent over.
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>'
}
});
Assuming data is an array of dictionaries, you're close:
$.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
}
精彩评论