Jump to content

$.eachJSON with multidimensional array


Lukeidiot

Recommended Posts

Hello I am trying to output the titles of each of the 10 results provided in the following JSON URL: https://www.googleapis.com/youtube/v3/search?part=snippet&q=test&maxResults=10&key=AIzaSyCoSXBJjRh7ToEJIMH2QF1-UsgK71E_RQ4

 

 

function populateRelated(searchTerm){

var search_input = searchTerm;
var keyword = encodeURIComponent(search_input);
var yt_url2 = 'https://www.googleapis.com/youtube/v3/search?part=snippet&q=' + keyword + '&maxResults=10&key=AIzaSyCoSXBJjRh7ToEJIMH2QF1-UsgK71E_RQ4';

$.getJSON(yt_url2, function(data) {

$.each(data, function(i,v){
$('#relatedsongs').append('<a class="dl" href="#" style="font-size: 12px;">' + items[0].id.videoId + '</a><br>');
console.log('worked');
});

});

}

The upper code DOES NOT work. Any idea how I can get it to output the titles for the results only?

 

Example
Video Title 1

Video Title 2

Video Title 3

...

Video Title 10

 

Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/296435-eachjson-with-multidimensional-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.