AnsweredAssumed Answered

not able to access variable outside $.ajax method

Question asked by ayushi.agrahari on Sep 7, 2017
Latest reply on Sep 8, 2017 by ayushi.agrahari

   I  am following GitHub - zhihailiu/alfresco-folder-size: Alfresco folder size to calculate the folder size and its working    fine,that is the folder size is showing as a separate component alongwith the properties of the folder but now I also want    to show the size in the document library of the folder.the following link contains the code

https://pastebin.com/ShL9EgrX

   

   when I am trying to access the variable size outside the jsonGet method,it is showing undefined that is the default value    of size

 



but after searching on internet,I learned that jsonGet is asynchronous,so it is exceuted after the synchronous code.so,I replaced the jsonGet method with $.ajax method and set the async to false to make $.ajax synchronous and access the variable outside the jsonGet method.but,still the variables "size" is undefined.

any help would be greatly appreciated.I am trying dis from many days



Outcomes