javascript - How can I pass arguments to the functions called by "jQuery then"? -


this question has answer here:

full code here: http://jsfiddle.net/burfz/ http://jsbin.com/dagequha/1/edit?js,console

/**  *   running work  */ func1('arg1').then(func2).then(func3).then(function () {     console.log('all done!'); });   /**  *   1 doesn't work  */ func1('arg1').then(func2('arg1')).then(func3('arg1', 'arg2')).then(function () {   console.log('all done!'); }); 

i have 3 async functions in code , i'm using jquery deferred/promise technique call them sequentially. it's working right problem can't pass these functions arguments. if run js bin(jsfiddle) sample see works, scroll down , use second commented section(the 1 arguments) instead of first 1 , stop working correctly. how can pass arguments func1, func2 , func3 , still call them sequentially?

try work

$.when(func1('arg1')).then(function(){     func2('arg1');}).then(function(){         func3('arg1','arg2');}).then(function () {              console.log('all done!'); }); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -