JSFiddle - React, Tailwind, and code Playground

by lshettyl

JavaScript

function doStuff() {
    
    var dfd = new jQuery.Deferred();
    alert ("loaded");
    setTimeout(function(){
        dfd.resolve("response - success");
    }, 5000);
    return dfd.promise();

}


$.when(doStuff()).then(function(status) {
    //runs when the timeout completes, in 5 seconds.
    alert(status + " function has finished executing...");
});