Created
March 4, 2012 16:32
-
-
Save winsonwq/1973776 to your computer and use it in GitHub Desktop.
upload images one by one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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