title: How to execute AJAX calls in order in loop using Javascript Promise
body: <p>I am looping through a map, where I want to make a separate AJAX call with each map value as parameter, to fetch some data and log it. See below. This is working, but I'd like to have the AJAX calls go in order of the map. Because each call is asynchronous, so seems like I should use promises to achieve execution in order. But I am new to promises and don't really know how to do it here. I have look elsewhere on here but could not find anything. Please help. </p>
  
  <pre><code>map.forEach(function(url, key) {
     log(url);
  });
  
  function log(url) {
      $.ajax({
        url: url, 
        dataType: 'json',
        success: function (result) {
            console.log(result.value);
            console.log(result.name);
            console.log(result.action);
        }
    });
  }
  </code></pre>