I have a program that, given an array of youtube video ids, calls the Youtube API and returns data about said videos. I do this by calling:
$.getScript("http://gdata.youtube.com/feeds/api/videos/"+encodeURIComponent(id)+"?v=2&alt=json-in-script&callback=youtubeFeedCallback");
This is done for each video id in the array. Is there a way to use ajaxStop to then do something (in my case modifying the DOM) once all of these requests finish? I am not doing this on any sort of .click or .mouseover or other such event, these requests are simply sent out when the page is loaded. I tried to do:
$.ajaxStop(function () { (do something here) });
But I got the following error: Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'ajaxStop'. Also will this work if some of the requests return 403 Forbiddens?
Edit: SOLVED
Fixed it, although my solution is a bit hacky. Instead of using $.getScript I instead just used the $.ajax function. I then had a global counter variable, and using the "error" method of $.ajax, incremented the count on error or on success. Then I just called what I wanted to when the count variable was equal to the length of my array. Id still love to hear if there is a better way to do this.