SO - 29688459
JavaScript
//the ajax request are modified to jsfiddle format
function getCategories() {
return $.post('/echo/json/', function (data) {
cats = 'categories';
console.log('getCategories')
});
}
function getLinks() {
return $.post('/echo/json/', function (data) {
links = 'links';
console.log('getLinks')
});
}
function getData() {
return $.post('/echo/json/', function (data) {
datavalue = 'data';
console.log('getData')
});
}
function init() {
console.log('init');
console.log('cats', cats);
console.log('links', links);
console.log('data', datavalue);
$("body").append("3 function are done!");
}
getCategories().then(function () {
var deferred = $.Deferred();
$.when(getLinks(), getData()).done(function () {
deferred.resolve();
});
return deferred.promise();
}).then(init);