title: Break AJAX for loop
body: <p>Newbie here. I have an Ajax function that loops through 3 different requests. However, if the first request fails, I want the other requests to terminate. I tried putting in a 'break' statement but got an 'Illegal break statement' error, I'm guessing since it's not directly inside the for loop, but rather two layers down. I can think of some messy ways to solve this issue, but I'm wondering what a good, simple solution would be...</p>
  
  <pre><code>function runQueries(request) {
  var reports = ['103, 187, 190'];
  for (i=0; i &lt; reports.length; i++) {
      report = reports[i];
      $.ajax({
      url: 'proxy.php',
      data: {requrl: request + '&amp;reportType=' + report},
      dataType: 'xml'
      })
      .done(function(response) {
          if ($(response).find('Locations').children('Location').length &lt; 1) {
              displayError(response, report);
              break;
          }
  </code></pre>