title: Can you have two ajax calls in one function that run on the same submit?
body: <p>I have one submit button for a function and for validation purposes, I need to have two ajax functions run when the submit is clicked. </p>
  
  <pre><code>    &lt;div class="form-group btn-group"&gt;
                    &lt;input type="button" class="btn btn-link" value="Back" onclick="history.back()"&gt;
                    &lt;input type="button" class="btn btn-primary" class="btn btn-link" value="View results" onclick="validateAndSubmit();"&gt;
                  &lt;/div&gt;
  
     async function validateAndSubmit() {
              $('.alert-danger').hide();
              $('.alert-text ul').text("");
  
              var hasError = false;
  
    &lt;cfif form.output_type eq "cl2stats"&gt;
  
        $('.alert-danger').hide().find('ul').empty();
        var monthYear1 = $("#date1").val();
        var date1 = monthYear1.slice(0, 3) + "01/" + monthYear1.slice(3, 7);
        const monthYear2 = $("#date2").val(),
          splitted = monthYear2.split('/'),
          month = splitted[0],
          year = splitted[1],
          date2 = `${month}/${new Date(year, month, 0).getDate()}/${year}`;
  
        await makeGetRequest({
          url: "url?method=validateDateRange",
          data: {date1: date1, date2: date2}
        })
                .done(function (response) {
                  if (response == "") {
                    document.getElementById("EIMEF_WATER_UTILITY_STATS").submit();
                  } else {
                    $('.alert-danger').show().find('ul').html(response);
                    hasError = true;
                  }
                  $(window).scrollTop(0);
                });
  
    &lt;/cfif&gt;
  
      if (hasError == false) {
        $.ajax({
          type: "POST",
          url: "url?method=regStatsExceedancesFilter2",
          dataType: "json",
          data: ({
            formString: formData
          }),
          success: function (response) {
            if (response == "success") {
              $('#EIMEF_WATER_UTILITY_STATS').trigger("submit");
            } else {
              $('.alert-danger').show();
              $('.alert-danger .alert-text ul').append(response);
              $(window).scrollTop(0);
            }
          },
          error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert("Status: " + textStatus + '\n' + "Error: " + errorThrown);
          }
        });
      }
    }
  </code></pre>
  
  <p>If the first ajax call returns an error, I need the form to stay on the page. Currently, if the first call returns an error, it moves to the next page.</p>