I can’t find an answer to this problem.
I’m trying to get the youtube video title (form WordPress of course, but I want to do it from javascript). Well my code looks like this:
$.ajax({
url: "http://youtube.com/get_video_info",
data: {video_id : v_arr[i]},
type: 'GET',
complete: function(jqXHR, res){
if(jqXHR.readyState === 4) {
alert(res);
}
alert(jqXHR.statusText);
}
});
The problem: on ‘complete’ I always get readyState 0 and except for the “error” in statusText I don’t get any helpful error message.
I tried running the ajax you provided and I got a 301 redirect response.
Looking at the youtube api I see the url being
https://gdata.youtube.com/feeds/api/videos/
which returns successI changed the url into what Circadian provided. The problem was also with i variable. As you see this is all happening inside a loop. So when the complete callback happened ‘i’ already had the last value from the loop… so when I accessed v_arr[i], there was the ‘undefined index’ problem.
The solution is “temp i”: