Fetching Youtube jSON info and appending to document

Fetching Youtube jSON info and appending to document

Hello! I was told I may find help here. I'm trying to fetch jSON info from Youtube on a videos, and then append them to the source but I'm having issues getting the JSON info into an array to use in my FOR loop where it goes over each video.... :\

This is what I'm attempting currently. 

  1. // Get youtube info
  2. function parseresults(target) {
  3. var parseResults = $.getJSON(target);
  4. return parseResults;
  5. }

  6. function getComments(commentsURL, startIndex) {
  7. $.ajax({
  8. url: commentsURL + '&start-index=' + startIndex,
  9. dataType: "jsonp",
  10. success: function (data) {
  11. $.each(data.feed.entry, function(key, val) {
  12. var returnArray = { 'author': val.author[0].name.$t, 'comment': val.content.$t };
  13. commentsArray.push(returnArray);
  14. });
  15. if ($(data.feed.entry).size() == 50) { getComments(commentsURL, startIndex + 50); }
  16. }
  17. });
  18. }
  19. function appendFeaturedVideos() {
  20. $.get('http://jordan.rave5.com/tmpstuff/featVideos.txt',function(data){
  21. var lineArray=data.split('\n'),
  22. slideList=[],
  23. featVids = $('#featured-video-links');
  24. count = lineArray.length;
  25. for(i = 0; i < count; i++) {
  26. var feedUrl = 'http://gdata.youtube.com/feeds/api/videos/' + lineArray[i] + '?v=2&alt=json',
  27. videoUrl = 'http://www.youtube.com/embed/' + lineArray[i] + '?fs=1';
  28. parseResults = parseresults(feedUrl);
  29. featVids.append('<div id="featured-video-link"><img src="' + parseResults['thumbnail']['sqDefault'] + '" alt="' + parseResults['title'] + '" /><div id="feat-vid-info"><div id="feat-vid-title"><div id="feat-vid-views">' + parseResults['viewCount'] + '</div>' + parseResults['title'] + '</div><p class="feat-vid-author">' + parseResults['uploader'] + '</p></div></div>');
  30. }
  31. });
  32. }
  33. $(document).ready(function() {
  34. appendFeaturedVideos();
  35. });