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.

if( source == 'vimeo' )
		url: '' + videoid + '.json',
		dataType: 'jsonp',
		success: function(data)
			thumbnail = data[0].thumbnail_medium;
if( source == 'youtube')
	thumbnail = '' + videoid + '/mqdefault.jpg';

// test result

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.