title: Triggering ajax calls after ajaxOncomplete causes infinite loop
body: <p>I have defined a general ajaxComplete function to be triggered after each ajax request as follow;</p>
  
  <pre><code>$(document).on('pfAjaxComplete', function(event, xhr, options) {
       doStuff();
  });
  </code></pre>
  
  <p>Note I use pfAjaxComplete instead of ajaxComplete to work under PrimeFaces</p>
  
  <p>Now, on each ajaxcomplete the 'doStuff()' function is being called. Problem is that inside the 'doStuff()' function I trigger several ajax calls to be executed based on a PrimeFaces remoteCommand</p>
  
  <pre><code>function doStuff() {
    var elements = $('#wrapper').find("[id*='elements']");
    if (elements !== null &amp;&amp; elements .length &gt; 0) {
       $.each(elements , function(index) {
         newAjaxCallBack([{name: 'param', value: 'val'}]);
       });
    }
  }
  </code></pre>
  
  <p>My remote command</p>
  
  <pre><code>&lt;p:remoteCommand name="newAjaxCallBack" actionListener="#{backingBean.action}" /&gt;
  </code></pre>
  
  <p>This is working fine, the backing bean action method is being called. Problem is the new ajax callback on 'doStuff' triggers a new ajaxOnComplete event, which makes sense of course but then it gets me on an infinite loop. Had tried to work it out but couldn't find any solution to it. </p>
  
  <p>Any ideas or suggestions? Would there be a way to send a parameter on the newAjaxCallBack and then detecting it on the ajaxComplete function so as to avoid the doStuff call? Thanks!</p>