Hey friends can you help me out with this issue. I have a JSON:
video_orders = {
"channel": {
"1": "relevance",
"2": "published",
"3": "viewCount",
"4": "rating"
},
"playlist": {
"1": "position",
"2": "commentCount",
"3": "duration",
"4": "published",
"5": "title",
"6": "viewCount"
},
"favorites": {
"1": "standard"
}
}
What i am trying to do is a Jquery each to get all values inside the keys like “channel”, “playlist”, “favorites”.
Currenly what i am doing is:
$(video_orders['channel']).each(function(index, value){
console.log(index+' : '+value);
})
So the output should be like:(if i do console.log)
1 : relevance
2 : published
3 : viewCount
4 : rating
But what i get is all wrong. What am i doing wrong? How can accomplish it?
Thanks in advance.
You’re using the wrong
each, you want$.each, not$(...).each:The
$(...).eachfunction is used to iterate over a set of matched DOM elements:The
$.eachfunction is:Demo: http://jsfiddle.net/ambiguous/Ax7Eu/