Is there a way to loop through JSON results using 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.
eg
$.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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.