Fun with Async.js
The fun begins here:
https://github.com/caolan/async
HTML
<script src="https://raw.github.com/caolan/async/master/lib/async.js"></script>
<h2>Fun with Async.js</h2>
<p>Let's see how this bad-boy rolls.</p>
<p>Read mor about <a href="https://github.com/caolan/async">Async.js</a> when you get a chance.</p>
<div id="bag1"></div>
<div id="bag2"></div>
<p><em>pssst ... don't forget to fire-up your inspector/firebug console</em></p>
<h3>Some other JSFiddle Examples</h3>
<ul>
<li><a href="http://jsfiddle.net/gYZhw/1/">http://jsfiddle.net/gYZhw/1/</a></li>
<li><a href="http://jsfiddle.net/WilsonPage/zvUmw/21/">http://jsfiddle.net/WilsonPage/zvUmw/21/</a></li>
<li><a href="http://jsfiddle.net/deanpeters/D3AKg/5/">http://jsfiddle.net/deanpeters/D3AKg/5/</a></li>
<li><a href=""></a></li>
</ul>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-442503-9']);
_gaq.push(['_setDomainName', 'deanpeters.com']);
_gaq.push(['_setCampNameKey', 'jsfiddle']);
_gaq.push(['_setCampMediumKey', navigator.userAgent ]);
_gaq.push(['_setCampSourceKey', 'internet']);
_gaq.push(['_setCampTermKey', 'javascript']);
_gaq.push(['_setCampContentKey', document.title ]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
JavaScript
async.series([
function(callback) {
// do some stuff ...
console.log('1');
callback(null, 'one');
},
function(callback) {
// do some more stuff ...
console.log('2');
callback(null, 'two');
}
],
// optional callback
function(err, results) {
// results is now equal to ['one', 'two']
});