<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic not able to access variable outside $.ajax method in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/not-able-to-access-variable-outside-ajax-method/m-p/27954#M11968</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;I&amp;nbsp; am following &lt;A class="link-titled" href="https://github.com/zhihailiu/alfresco-folder-size" title="https://github.com/zhihailiu/alfresco-folder-size" rel="nofollow noopener noreferrer"&gt;GitHub - zhihailiu/alfresco-folder-size: Alfresco folder size&lt;/A&gt; to calculate the folder size and its working &amp;nbsp;&amp;nbsp;&amp;nbsp;fine,that is the folder size is showing as a separate component alongwith the properties of the folder but now I also want &amp;nbsp;&amp;nbsp;&amp;nbsp;to show the size in the document library of the folder.the following link contains the code&lt;/P&gt;&lt;P&gt;&lt;A class="jivelink2" href="https://pastebin.com/ShL9EgrX" title="https://pastebin.com/ShL9EgrX" rel="nofollow noopener noreferrer"&gt;https://pastebin.com/ShL9EgrX&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;when I am trying to access the variable size outside the jsonGet method,it is showing undefined that is the default value &amp;nbsp;&amp;nbsp;&amp;nbsp;of size&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;any help would be greatly appreciated.I am trying dis from many days&lt;/P&gt;&lt;CODE&gt;&lt;SPAN class=""&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Sep 2017 12:54:01 GMT</pubDate>
    <dc:creator>ayushi_agrahari</dc:creator>
    <dc:date>2017-09-07T12:54:01Z</dc:date>
    <item>
      <title>not able to access variable outside $.ajax method</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/not-able-to-access-variable-outside-ajax-method/m-p/27954#M11968</link>
      <description>&amp;nbsp;&amp;nbsp;&amp;nbsp;I&amp;nbsp; am following GitHub - zhihailiu/alfresco-folder-size: Alfresco folder size to calculate the folder size and its working &amp;nbsp;&amp;nbsp;&amp;nbsp;fine,that is the folder size is showing as a separate component alongwith the properties of the folder but now I also want &amp;nbsp;&amp;nbsp;&amp;nbsp;to show the size in the document library of t</description>
      <pubDate>Thu, 07 Sep 2017 12:54:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/not-able-to-access-variable-outside-ajax-method/m-p/27954#M11968</guid>
      <dc:creator>ayushi_agrahari</dc:creator>
      <dc:date>2017-09-07T12:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: not able to access variable outside $.ajax method</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/not-able-to-access-variable-outside-ajax-method/m-p/27955#M11969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Ayushi Agrahatri&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try by Initialize the variable size,&lt;/P&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; size &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you are calling a printSize() function then you can pass your size variable in that function&lt;/P&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;printSize&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;size&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And you can get it in your function&lt;/P&gt;&lt;PRE class="language-javascript line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;printSize&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;folderSize&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;BR /&gt; console&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;log&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;folderSize&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Kalpesh&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.contcentric.com" rel="nofollow noopener noreferrer"&gt;ContCentric&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2017 14:48:54 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/not-able-to-access-variable-outside-ajax-method/m-p/27955#M11969</guid>
      <dc:creator>kalpesh_c2</dc:creator>
      <dc:date>2017-09-07T14:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: not able to access variable outside $.ajax method</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/not-able-to-access-variable-outside-ajax-method/m-p/27956#M11970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yupp thanks for dis but I am actually trying to execute the last html statement inside the printsize function so as to show the size of folder in document library but after a little testing,I get to know that html statement is executed properly if it remains only inside the renderer function and not in any other function(e.g. even not inside the printsize function)&lt;/P&gt;&lt;P&gt;How to execute that html statement with size having the value that is manipulated inside the ajax function rather than the default value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Sep 2017 14:19:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/not-able-to-access-variable-outside-ajax-method/m-p/27956#M11970</guid>
      <dc:creator>ayushi_agrahari</dc:creator>
      <dc:date>2017-09-08T14:19:39Z</dc:date>
    </item>
  </channel>
</rss>

