SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting Vimeo Thumbnail with jQuery

    Hi everyone,

    I have some trouble getting this to work, I'm trying to grab the Vimeo video thumbnail value to use it further down the javascript lines.

    HTML Code:
    <script>
    ......
    if( source == 'vimeo' )
    {
    	$.ajax({
    		url: 'http://www.vimeo.com/api/v2/video/' + videoid + '.json',
    		dataType: 'jsonp',
    		success: function(data)
    		{
    			thumbnail = data[0].thumbnail_medium;
    		}
    	});
    }
    else
    if( source == 'youtube')
    {
    	thumbnail = 'http://i4.ytimg.com/vi/' + videoid + '/mqdefault.jpg';
    }
    
    // test result
    alert(thumbnail);
    ......
    </script>
    For some reason, the "thumbnail" value is not preserved outside the ajax call, I suspect it's because I'm defining it wrongly. How would I go about doing it properly so that I could actually use the thumbnail value, please?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by andROO View Post
    For some reason, the "thumbnail" value is not preserved outside the ajax call, I suspect it's because I'm defining it wrongly. How would I go about doing it properly so that I could actually use the thumbnail value, please?
    The success function is not run right away, so anything that you want done will need to be triggered from that success function itself.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •