title: Multifunctioning in Javascript (jQuery)
body: <p>The <strong>concept</strong> is running multiple functions concurrently.</p>
  
  <p>The <strong>reason</strong> is, I have a page which performs various actions through ajax. These actions includes making multiple backups of new files uploaded in the upload directory. But I want this process to be initiated by a moderator. </p>
  
  <p>As this is a very lengthy process(might even take hours to complete), it blocks others ajax requests from executing, until this process complete.</p>
  
  <p>I want to execute functions along with the previously executed function parallelly. </p>
  
  <p>I am using jQuery's Ajax to sent initiate the request.</p>
  
  <p>I will try to explain using a example</p>
  
  <hr>
  
  <p>I use ajax  request to perform a server side action. These requests are initiation on click event of a anchor text.</p>
  
  <pre><code>$(".ajax").live('click',function() {
       action = $(this).attr['rel'];
       $.post(
           'proccess.php',
           { action: action }, //among many action one is for the backup
           function(data) {
              //once a particular action is complete check the data to decide if it requires to continue
              flag = data.flag;
              // if the action fails or if action is backup then the flag is true
              if(flag) {
                  //reexecute the same function
                  $(this).trigger('click');
              }
           },'json'
       );
  });
  </code></pre>
  
  <p>In the case if action=='Backup', it backups one file at a time then responds to the script with the json with a true flag and success message to notify about the progress and reexecutes the same function. </p>
  
  <p>Where as other actions will include actions to view the backup log, errors, and other actions that are not even related backup.</p>
  
  <p>So once I click the backup option to initiate the backup progress, I cannot execute other actions</p>
  
  <p>But I am using trigger to initiate another request because if multiple function trigger is pending and the function has finished backing up one file then before sending another call of same function it executes the pending function execution first.</p>
  
  <hr>
  
  <p>But I need a better solution, and for that I need to execute multiple instances of a same function many times.</p>