title: Nested Ajax request, good or bad practice?
body: <p>I have to make a sequence of Ajax post requests to server using jQuery, and each request is depends on the result of previous response, for example</p>
  
  <pre>
  preprocessing-data-Ajax(returns jobs_array){
      register-job-Ajax(returns job_id){
         for each prepared data index i{
             submit_job_Ajax(job_id, jobs_array[i]){
                 if(last_returned_job){
                     unregister_job-Ajax(jon_id){
                         postprocessing-data-Ajax;
                     }                   
                 }
             }
         } 
      }
  
  }
  </pre> 
  
  <p>This creates a huge chunk of unreadable code and very hard to debug. Just wondering if anyone knows how to avoid nested Ajax requests, or points me to an alternative solution.</p>
  
  <p>Thanks!</p>