개발자의 끄적끄적

[javascript & jquery] vimeo 영상 존재여부 체크 본문

개발/javascript & jquery

[javascript & jquery] vimeo 영상 존재여부 체크

효벨 2019. 12. 18. 13:42
728x90
반응형

[javascript & jquery] vimeo 영상 존재여부 체크

 

 


function checkIfVideoExists(url, callback){
    $.ajax({
        type:'GET',
        url: 'https://vimeo.com/api/oembed.json?url=' + encodeURIComponent(url),
        dataType: 'json',
        complete: function(xhr) {
            callback(xhr.status);
        } 
    });
}

checkIfVideoExists("https://vimeo.com/217775903", function(status){
    console.log(status); // 200 - OK
});

checkIfVideoExists("https://vimeo.com/234242343", function(status){
    console.log(status); // 404 - Not found
});

 

 

반응형
Comments