doforumda Posted June 6, 2011 Share Posted June 6, 2011 hi I am fetching thumbnails of youtube videos but it does not show up. I am doing this using PHP, JQuery ajax. The problem is it does not show any error. it displays all the links to thumbnails but it does not display it. Here is my code <?php require("database/db.php"); include "functions/ytVideoId.php"; $getVideos = mysql_query("SELECT * FROM dc_videos LIMIT 9"); if(mysql_numrows($getVideos) > 0) { while($rowVideos = mysql_fetch_assoc($getVideos)) { $video = $rowVideos['videoUrl']; $videoId = ytVideoId($video); echo "http://i1.ytimg.com/vi/$videoId/default.jpg "; } } else echo "No videos found!"; ?> here is my javascript file $(function() { $('#tabBody').click(function(){ $('#tabBody').addClass('tabActive'); //alert("hello"); var url = "videos.php"; $.ajax({ type: 'POST', url: url, success: function(result) { alert(result); $('#videoList').html("<img src='" + result + "' alt='Preview Not Available' />"); } }); }); }); this is what i get as a result in js file http://i1.ytimg.com/vi/VjWJhA_4M9g/default.jpg http://i1.ytimg.com/vi/Rln9Z7w1A1w/default.jpg http://i1.ytimg.com/vi/GXK6tf16ue8/default.jpg http://i1.ytimg.com/vi/Uq1jsb9LqHo/default.jpg http://i1.ytimg.com/vi/Yg7K36i8B4c/default.jpg http://i1.ytimg.com/vi/YVwcbI8iuxo/default.jpg http://i1.ytimg.com/vi/xqvxlhqGHTY/default.jpg http://i1.ytimg.com/vi/PHk302o4VFk/default.jpg http://i1.ytimg.com/vi/hSuik_fu-WM/default.jpg please help Quote Link to comment Share on other sites More sharing options...
Adam Posted June 7, 2011 Share Posted June 7, 2011 What's the HTML structure you're working with? Looks like the script is returning multiple image paths, and you're setting them all as one long string to the src attribute. Quote Link to comment Share on other sites More sharing options...
doforumda Posted June 7, 2011 Author Share Posted June 7, 2011 ok here is my html page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link type="text/css" rel="stylesheet" href="css/styles.css" /> <script type="text/javascript" src="js/jquery-lib.js"></script> <script type="text/javascript" src="js/script.js"></script> <title>Dream City</title> </head> <body> <?php $_SESSION['userid'] = "1"; $_SESSION['username'] = "zafar"; ?> <div id="contents"> <div id="tabsContainer"> <div id="tabBody" class="tabs">Body</div> <div id="tabMind" class="tabs">Mind</div> <div id="tabBusiness" class="tabs">Business</div> <div id="tabArts" class="tabs">Arts</div> <div id="tabEnvironment" class="tabs">Environment</div> </div><!-- tabsContainer --> <div id="tabsContentsWrapper"> <div class="haveYourDefinition" id="haveYourDefinition">Have your Definition</div><!-- haveYourDefinition --> <div id="videosList" class="list"><ul></ul><div id="videosLoader"></div></div> <div class="haveYourDefinitionFooter">Video Title / Username / Date</div> <div class="haveYourDefinition">Have your Definition</div><!-- haveYourDefinition --> <div class="list">Photos</div> <div class="haveYourDefinitionFooter">Video Title / Username / Date</div> </div><!-- tabsContents --> </div><!-- contents --> </body> </html> Quote Link to comment Share on other sites More sharing options...
Adam Posted June 7, 2011 Share Posted June 7, 2011 You need to loop through the result data and append() the image HTML for each. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.