var urlYouTube = "http://gdata.youtube.com/feeds/api/videos?vq=" + searchTerm + "&max-results=42&orderby=published&alt=json";
$.getJSON(urlYouTube, function (data) {
// Loop through each feed entry
$.each(data.feed.entry, function (i, item) {
// Get the URL for the video
var url = item.link[0].href;
// Get the title of the video
var title = item.title.$t;
// Get the first 10 characters of date video was published or: YYYY-MM-DD
var datepublished = item.published.$t.substring(0, 10);
// Get the author name
var author = item.author[0].name.$t;
// Get the thumbnail image for the video
var thumbnailURL = item.media$group.media$thumbnail[0].url;
// Construct the display for the video
var text =
"<br><a href='" + url + "'>" + title + "</a><br>" +
"Published: " + datepublished + " by " + author + "<br><br>" +
"<img src='" + thumbnailURL + "'><br>";
// Append the text string to the div for display
$("#dynaMashTab-YouTube").append(text);
});
});