Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

You should use jQuery Promises

http://www.shillier.com/archive/2013/03/04/using-promises-with-the-javascript-client-object-model-in-sharepoint-2013.aspx

doSomething()
.then(doSomethingElseWhenThatsDone, orHandleAnError)
.then(doYetAnotherThingWhenThatsDone, orHandleAnError);

function doSomething(){
   //set up some JSOM stuff
   var dfd = $.Deferred();
   context.executeQueryAsync(
    function () {
        dfd.resolve();
    }, function (sender, args) {
        dfd.reject(sender, args, errorMsg);
    });
   return dfd.promise()
}

http://stackoverflow.com/questions/22411220/how-do-i-get-the-executequeryasync-to-behave-more-synchronuslyhttps://stackoverflow.com/questions/22411220/how-do-i-get-the-executequeryasync-to-behave-more-synchronusly

You should use jQuery Promises

http://www.shillier.com/archive/2013/03/04/using-promises-with-the-javascript-client-object-model-in-sharepoint-2013.aspx

doSomething()
.then(doSomethingElseWhenThatsDone, orHandleAnError)
.then(doYetAnotherThingWhenThatsDone, orHandleAnError);

function doSomething(){
   //set up some JSOM stuff
   var dfd = $.Deferred();
   context.executeQueryAsync(
    function () {
        dfd.resolve();
    }, function (sender, args) {
        dfd.reject(sender, args, errorMsg);
    });
   return dfd.promise()
}

http://stackoverflow.com/questions/22411220/how-do-i-get-the-executequeryasync-to-behave-more-synchronusly

You should use jQuery Promises

http://www.shillier.com/archive/2013/03/04/using-promises-with-the-javascript-client-object-model-in-sharepoint-2013.aspx

doSomething()
.then(doSomethingElseWhenThatsDone, orHandleAnError)
.then(doYetAnotherThingWhenThatsDone, orHandleAnError);

function doSomething(){
   //set up some JSOM stuff
   var dfd = $.Deferred();
   context.executeQueryAsync(
    function () {
        dfd.resolve();
    }, function (sender, args) {
        dfd.reject(sender, args, errorMsg);
    });
   return dfd.promise()
}

https://stackoverflow.com/questions/22411220/how-do-i-get-the-executequeryasync-to-behave-more-synchronusly

Source Link
Amal Hashim
  • 28.4k
  • 5
  • 32
  • 61

You should use jQuery Promises

http://www.shillier.com/archive/2013/03/04/using-promises-with-the-javascript-client-object-model-in-sharepoint-2013.aspx

doSomething()
.then(doSomethingElseWhenThatsDone, orHandleAnError)
.then(doYetAnotherThingWhenThatsDone, orHandleAnError);

function doSomething(){
   //set up some JSOM stuff
   var dfd = $.Deferred();
   context.executeQueryAsync(
    function () {
        dfd.resolve();
    }, function (sender, args) {
        dfd.reject(sender, args, errorMsg);
    });
   return dfd.promise()
}

http://stackoverflow.com/questions/22411220/how-do-i-get-the-executequeryasync-to-behave-more-synchronusly