dimanche 11 août 2019

How to run the call back after the IF/else statement is completed

I have if and else statements and one update function that will work based on the completion of the if statement. I want to run a callback to make sure it only run when any of the branches is completed.

if (source !== "itunes"){
    getCustomCover(title);
}
else {
    getiTuensCover(iTunes_data);
}

updateCover(currentCoverURL);

So I want to make sure the updateCover(currentCoverURL); is running when getCustomCover(title); is completed. The same thing for the else branch. Something like $.when() & then().

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire