<?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 Re: Ajax requests in a for-loop? (Blog Dashlet) in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/ajax-requests-in-a-for-loop-blog-dashlet/m-p/277826#M230956</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When Alfresco.util.Ajax.request is making an XMLHttpReqest against the server it is doing that as an "asynchronous" call, meaning it will not wait for the server response before the function "ends". Instead it lets the user of the method provide callback methods for success and failure, which I can see that you have done.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even though its possible (probably in most browsers, even though I have not tested it) to make an synchronous XMLHttpRequest (waiting for the server response) I wouldn't recommend it as a solution because it would make the user experience feel slower since you have to wait for the responses before the remaining code executes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you necessarily want to keep the code in your browser you would have to "chain/recurse" the calls for the sites in your successCallback method. In other words keep track of an array with the sites that blogs shall be loaded for. Every site that has got its blogs loaded would be removed from the array until there are none left.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another solution is to create a new webscript (in the repo) that takes a list of sites that it shall load blogs for. Then instead of having a for loop in your client side javascript code you would just make 1 call to your new webscript which would loop thought the sites and load blogs for them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers and good luck,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Erik&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Mar 2012 08:59:55 GMT</pubDate>
    <dc:creator>erikwinlof</dc:creator>
    <dc:date>2012-03-21T08:59:55Z</dc:date>
    <item>
      <title>Ajax requests in a for-loop? (Blog Dashlet)</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/ajax-requests-in-a-for-loop-blog-dashlet/m-p/277825#M230955</link>
      <description>I'm currently modifying the Blog Dashlet to be a user dashlet that displays the blog posts from all sites of a member.I succeeded at this (the displaying part, I don't need the "create post" functionality) , but stumbled upon a few odds.If I bundle Ajax Requests in a for-loop, the loop terminates be</description>
      <pubDate>Tue, 20 Mar 2012 12:56:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/ajax-requests-in-a-for-loop-blog-dashlet/m-p/277825#M230955</guid>
      <dc:creator>tbarg</dc:creator>
      <dc:date>2012-03-20T12:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Ajax requests in a for-loop? (Blog Dashlet)</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/ajax-requests-in-a-for-loop-blog-dashlet/m-p/277826#M230956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When Alfresco.util.Ajax.request is making an XMLHttpReqest against the server it is doing that as an "asynchronous" call, meaning it will not wait for the server response before the function "ends". Instead it lets the user of the method provide callback methods for success and failure, which I can see that you have done.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even though its possible (probably in most browsers, even though I have not tested it) to make an synchronous XMLHttpRequest (waiting for the server response) I wouldn't recommend it as a solution because it would make the user experience feel slower since you have to wait for the responses before the remaining code executes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you necessarily want to keep the code in your browser you would have to "chain/recurse" the calls for the sites in your successCallback method. In other words keep track of an array with the sites that blogs shall be loaded for. Every site that has got its blogs loaded would be removed from the array until there are none left.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another solution is to create a new webscript (in the repo) that takes a list of sites that it shall load blogs for. Then instead of having a for loop in your client side javascript code you would just make 1 call to your new webscript which would loop thought the sites and load blogs for them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers and good luck,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Erik&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2012 08:59:55 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/ajax-requests-in-a-for-loop-blog-dashlet/m-p/277826#M230956</guid>
      <dc:creator>erikwinlof</dc:creator>
      <dc:date>2012-03-21T08:59:55Z</dc:date>
    </item>
  </channel>
</rss>

