I have the following:
function functionA() {
var myVar = functionB();
functionC(myVar);
}
the time, functionB needs to answer, depends on user input. It may be 1s, but also 10s. So functionC always is called with an undefined value, because functionB() hasnt't finished yet. So I tried this:
function functionA() {
var def = $.Deferred();
var myVar = functionB();
def.resolve();
$.when(def).done(function () {
functionC(myVar);
});
}
This also doens't work. I saw this on StackOverflow: javascript function wait until another function to finish But how can it be transferred to my problem? To recap, execution of functionA needs to stop, until functionB() has answered. Thanks.