It is hard to say what you are trying to do with these promises. First you call all 4 functions, and then try to connect them with a then callback chain. If you want to consistently combine them together, it should look like this:
functiond1() .then(functiond2) .then(functiond3) .then(functiond4) .done(function() { });
If you want the result to be completed, you can use $.when
$.when(functiond1(), functiond2(), functiond3(), functiond4()) .then(function(resultd1, resultd2, resultd3, resultd4) { });
On the other hand, in your functions, you create promises that are allowed in the done callback of another promise that is not needed. Calls to $.getJSON.done() return a promise, so no additional promise is required. Just return the promise returned with done() .
Sorry, I haven't messed up a lot with deferred jQuery objects, but they seem pretty similar to standard promises.
source share