JSFiddle - React, Tailwind, and code Playground

by Eric Hynds

JavaScript

// open your console!

function getData() {
    return $.get('/echo/html/');
}

function sweetAnimation() {
    var dfd = $.Deferred();

    setTimeout(function() {
        dfd.resolve('hi!');
    }, 1000);

    return dfd.promise();
}

$.when(getData(), sweetAnimation()).then(function(ajaxResult, animationResult) {
    console.log('my awesome animation AND the AJAX request are both done!');

    // ‘ajaxResult’ is the server’s response
    // ‘animationResult’ is “hi!”
});