title: http request in while loop in JavaScript
body: <p>I am trying to send a xmlHttpRequest in a while loop and want to do something with the response in the same while loop. Since the requests are asynchronous, how can I achieve it? I need to execute everything serially</p>
  
  <pre><code>while(i &lt; n){
   response = self.sendHttpRequest(params);
   //do something with the response
  }
  </code></pre>
  
  <p>Any help would be appreciated.
  Even If I use a callback, how can I get back to same while loop after executing the callback?</p>