Reputation: 1706
Can anyone see what i am doing wrong here? the youtube one is working but its not adding the image from thevideoThumbV function and cant work out why...
fiddle: https://jsfiddle.net/yurt5bb6/3/
function:
function videoThumbV(id) {
$.ajax({
type:'GET',
url: '//vimeo.com/api/v2/video/' + id + '.json',
jsonp: 'callback',
dataType: 'jsonp',
success: function(data){
var thumbnail_src = data[0].thumbnail_large;
return '<img class="vimeo-thumb" src="' + thumbnail_src + '"><div class="play-button"></div>';
}
});
}
Upvotes: 1
Views: 948
Reputation: 66650
You can't return stuff from synchronous call, you need to use a callback:
function videoThumbV(id, callback) {
$.ajax({
type:'GET',
url: '//vimeo.com/api/v2/video/' + id + '.json',
jsonp: 'callback',
dataType: 'jsonp',
success: function(data){
var thumbnail_src = data[0].thumbnail_large;
callback('<img class="vimeo-thumb" src="' + thumbnail_src + '"><div class="play-button"></div>');
}
});
}
videoThumbV(id, function(str) {
player.html(str);
});
Upvotes: 1