Something a little fancy that you can reuse throughout the site. Should work fine.
var Loader = function () {
var options = arguments[0];
this.actions = options.actions;
if (!this.actions || !this.actions.length) {
throw 'Loader: FATAL ERROR: Nothing to do. All your base are belong to us.';
}
this.onComplete = options.onComplete || function () {};
this.next();
}
Loader.prototype = {
next: function () {
if (this.actions.length) {
var action = this.actions.pop(), me = this;
$(action.selector).load(action.url, action.data, me.next);
} else {
this.onComplete();
}
}
}
var loaders = []; // or maybe asingle variable you overwrite every time, I don't know
$("#sidebar a").live("click", function(e){
$(this).addClass("selected loading");
loaders.push(new Loader({
actions: [
{selector: "#conceptual", url: conceptualUrl, data: null},
{selector: "#development", url: developmentUrl, data: null},
{selector: "#operational", url: operationalUrl, data: null}
],
onComplete: function () {
$("#sidebar a.loading").removeClass("loading");
}
}));
});
Of course you can modify the Loader to make it more powerful; add methods to enqueue new actions or drop the one currently running, maybe make it more general. Mine is just a quick and dirty example :)