One of the successful workloads is:
http://gdata.youtube.com/feeds/api/videos/N7m86aMNjlQ?callback=jsonp1335008664824&alt=json-in-script
However, when the video is private or does not exist, it only returns a message with the error status code http.
http://gdata.youtube.com/feeds/api/videos/zkZBEnBjOjY?callback=jsonp1335008664915&alt=json-in-script
I create an example of a unique callback function name like "jsonp1335008664824" and add url as src for the script tag and catch the function when the script loads. However, if it returns an error, youtube does not return the contents as a callback function, and I cannot catch them. Since the script tag does not have the "onerror" attribute, I donโt even know if it loaded or returned an error, such as 404 or 503 status codes.
It seems the only one he can handle is setting the timeout function when I add the script tag. However, this is not a reliable way to do this, so I am looking for another option. I know that even I can catch the status code, I canโt get an error message, but, as I see, there are only two status codes and two errors 404 for "Video not found" or 503 for "Video - personal".
source
share