JSFiddle - React, Tailwind, and code Playground

JavaScript

doAjax(4, function () {
    console.log("finished ajax");
});

function doAjax(delay, callback) {
    $.ajax({
        type: "post",
        url: "/echo/html/",
        data: {
            html: "some content",
            delay: 4
        },
        dataType: 'html',
        success: function () {
            console.log("ajax done");
        }
    });

    if (typeof callback == "function") callback();
}