JSFiddle - React, Tailwind, and code Playground

by Matt Ball

JavaScript

// open your console
    
function foo () {
    var dfd = $.Deferred();
    console.log('foo');
    dfd.resolve();
    return dfd.promise();
}

function ajaxCall1() {
    return $.ajax({
        type: 'POST',
        dataType: 'json',
        url: '/echo/json/',
        data: { },
        success: function(response) {
            console.log('ajaxCall1 success');
        }
    });
    return dfd.promise();
}

function ajaxCall2() {
    return $.ajax({
        type: 'POST',
        dataType: 'json',
        url: '/echo/json/',
        data: { },
        success: function(response) {
            console.log('ajaxCall2 success');
        }
    });
    return dfd.promise();
}

function ajaxCall3() {
    return $.ajax({
        type: 'POST',
        dataType: 'json',
        url: '/echo/json/',
        data: { },
        success: function(response) {
            console.log('ajaxCall3 success');
        }
    });
    return dfd.promise();
}

foo().done(function () {
    ajaxCall1().done(function () {
        ajaxCall2().done(function () {
            ajaxCall3();
        });
    });
});