Chain functions with deferred and promises but without setTimeout ...
Hi Guys
I need to execute 2 functions one after the other with the stuff in function "A" fully completing before the stuff in function "B" executes...
I can't find an example that is not using setTimeout .. which is strange ...
I have the following example below (
from here ) , is it supposed to work ?? How could I test if it is working ? what dummy code could I use to simulate the part
//do stuff with SharePoint JSOM taking 5 secs to 30 secs ,say ...
- var a = function() {
- var defer = $.Deferred();
-
- //do stuff with SharePoint JSOM
- console.log('a() called');
- defer.resolve();
- return defer;
- };
- var b = function() {
- var defer = $.Deferred();
- console.log('b() called');
- defer.resolve();
- return defer;
- };
- a().then(b);