javascript - How to alter a promise chain? -


in chain promises there way have 1 of members add promises chain?

this code illustrates better mean:

$.ajax(......).then(function(r){    .....   return r;  }).then(function(r){    var d = $.deferred();   // how add d.promise() chain ?   ....   return r;  }).then(function(r){    // function should able receive "r"   // should wait promise above complete :(    .... }); 

i don't have experience jquery promises can pay promise one, nicolas bevacqua explain in ponyfoo article es6 promises in depth.

var p = promise.resolve()   .then(data => new promise(function (resolve, reject) {     settimeout(math.random() > 0.5 ? resolve : reject, 1000)   }))  p.then(data => console.log('okay!')) p.catch(data => console.log('boo!')) 

i hope can adapt needs or maybe use native promises instead.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -