JSFiddle - React, Tailwind, and code Playground

by Eric Howe

HTML

<button id="go">click</button>

JavaScript

$('#go').click(function() {
    $(this).after('<div id="loading">Loading...</div>');
    setTimeout(function() {
        $.ajax({
            url: '/echo/html/',
            type: 'post',
            async: false,
            data: {
                html: '<p>pancakes</p>',
                delay: 3
            },
            success: function(data) {
                console.log(data);
                $('#go').after(data);
            },
            error: function() {
                alert('Busted!');
            },
            complete: function() {
                $('#loading').remove();
            }
        });
    }, 0);
});