I am really new to Javascript and Json and need help with the following. This is some json data:
"genres": [
{
"id": 28,
"name": "Action"
},
{
"id": 18,
"name": "Drama"
},
{
"id": 14,
"name": "Fantasy"
},
{
"id": 36,
"name": "History"
}
],
Now I would like to output all names of genres
I'm working with jquery mobile and ajax to retrieve json data. Inside my function it looks sth like this:
var genres = results.genres[0].name;
$('#tmdbInfo2').html('<br>Genres: ' +genres);
In this example the first element of genres will we shown (Action), but not all. The output should be: Action, Drama, Fantasy, History. Sometimes the number of elements of genres varies..
Please help me, its very confusing for me O_o