Conditionals on a chained deferred in jquery
Let say I chained the $.Deferred like this. $.each(data, function(k, v) { promise.then(function() { return $.post(...); }).then(function(data) { if(data)... // here is the conditions return $.post(...); }).then(function(data) { if(data)... // here is another condition return $.post(...); }) }); promise.done(function() { console.log("All Done!"); }); Am I doing it right? how do I prevent the next chain to execute if the condition return false, and where do I do this: if(data){ console.log('Success'); } Can that code be in between those .then s? Joey, whether or not you are doing it right