JSFiddle - React, Tailwind, and code Playground

by Ravindra Athreya

JavaScript

Promise.all([ajax1(), ajax2()]).then(() => { // try removing ajax 1 or replacing with ajax2
    alert('All Ajax done with success!')
  }).catch((response) => {
    alert('All Ajax done: some failed!')
  })

  function ajax1() {
    return $.ajax({
      url: "http://www.someURl.com", // fake URL, will throw error     
      type: 'post',
      success: function(jsonSaveResponse) {
        alert("successs 1");
      },
      error: function(jqXHR, textStatus, errorThrown) {
        alert("error 1");
      }
    });
  }

  function ajax2() {
    return $.ajax({
      url: "http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", // from w3schools
      type: 'GET',
      success: function(jsonSaveResponse) {
        alert("successs 2");
      },
      error: function(jqXHR, textStatus, errorThrown) {
        alert("error 2");
      }
    });
  }