I am having the following code where realurl = 'TOwd30wXc-0' (youtube video ID):
$.ajax({
url: "http://gdata.youtube.com/feeds/api/videos/"+realurl+"?v=2&alt=json-in-script",
dataType: "jsonp",
contentType: "application/json; charset=utf-8",
success: function (data) { PreviewVideo(data) }
});
Where PreviewVideo(data) is the function that parses json response and does other things with it.
My problem is, if video ID is incorrect (doesn't exist), I am not receiving any notice about that. I have tried adding error: function() { alert('error occured') }
into $.ajax but it simply does nothing.
Does anybody know a way how to determine if video is okay or not? If video exists, call PreviewVideo(data), else - call VideoError() ?
EDIT: If I put invalid ID, im getting
GET http://gdata.youtube.com/feeds/api/videos/TOwd30wXc-?v=2&alt=json-in-script&callback=jQuery17205096300751902163_1353530502856&_=1353530692237 400 (Bad Request)
in the javascript console (Chrome)
Thanks in advance