How to use result obtained from clientContext.executeQueryAsync

i have to use result obtained from clientContext.executeQueryAsync for condition in code.But, now i face problem that clientContext.executeQueryAsync result not obtained when needed.

=================

1

 

Please provide more information about how you are using it, the code used, any error messages and so on.
– Robban1980
Jan 29 ’15 at 5:15

  

 

Hi, i am using function called getList(CourseId).done(function (result) {} This function is using Deferred as function getList(CourseId) { var d = $.Deferred(); var CourseApprovList = oListCA.getItems(camlQueryCA); clientContextCA.load(CourseApprovList);}
– user3724710
Jan 29 ’15 at 12:01

=================

1 Answer
1

=================

You can make use of Jquery Promises and deferreds for making use of result in success call back.
Below is the Reference blog.qumsieh.ca/2013/10/31/using-jquery-promises-deferreds-with-sharepoint-2013-jsom/

“When you call ExecuteQueryAsync in JSOM on the client side, it executes the object model code you declared and carries on immediately! Then at some point in the future it returns. This is an asynchronous call.

This is challenging because rarely do we need to do a single thing with the object model and quite often we need to act on the result of that execution. So we need to wait and then do something.

How do we handle this?

The answer is promises. Promises is simply a programming paradigm that deals with the challenges of asynchronous calls. It does this by deferring the execution of some work until something else has finished.”

  

 

ok, i am trying that!
– user3724710
Jan 29 ’15 at 4:26

  

 

my challenge is that the P.done method is executed but return value of done is observed to be undefined when in debug p.done(function(result) {}
– user3724710
Jan 29 ’15 at 8:55

  

 

Hi, i got data in .done fuction right now i am trying to use that data outside the done function is any way to use that data outside.
– user3724710
Jan 29 ’15 at 12:00