Skip to content

Instantly share code, notes, and snippets.

@balanza
Created October 27, 2015 00:53
Show Gist options
  • Select an option

  • Save balanza/06fbdbf6c1a67d529319 to your computer and use it in GitHub Desktop.

Select an option

Save balanza/06fbdbf6c1a67d529319 to your computer and use it in GitHub Desktop.
//array of async resources to be loaded
var paths = ['file1.xml', 'file2.xml', 'file3.xml'];
//the callback for the ajax call
var callback = function(fileIndex){
alert('this is a callback for file ' + paths[fileIndex]);
};
//generates ajax calls
for(var i=0; i<=paths.length; i++){
ajax.get('http://foo.com/' + paths[i], _.partial(callback, i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment