Skip to content

Instantly share code, notes, and snippets.

@winsonwq
Created March 4, 2012 16:32
Show Gist options
  • Save winsonwq/1973776 to your computer and use it in GitHub Desktop.
Save winsonwq/1973776 to your computer and use it in GitHub Desktop.
upload images one by one
require(['./lib/Mr.Async', './lib/Recoder/main'], function(Mr, interpreter){
function asyncUpload(image){
var dfd = Mr.Deferred();
ajaxPost(image, function(ret){
if(ret.status == 200){
dfd.resolve();
}
});
return dfd;
}
var uploadImages = eval(interpreter.recode(function(images){
for(var i = 0, len = images.length; i < len ; i++){
$await(asyncUpload(images[i]));
}
}));
var images = [/*...*/];
uploadImages.start(images);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment