JSFiddle - React, Tailwind, and code Playground

HTML

<div id="status"></div>

JavaScript

function checkConnection() {
    $.ajax({
        url: '/echo/json/',
        type: "POST",
        success: function () {
            showStatus("All good");
        },
        error: function () {
            showStatus("Maybe you're offline...");
        }
    }).complete(function () {
        setTimeout(checkConnection, 1000);
    });
}

function showStatus(status) {
    $("#status").text(status);
}

$(document).ready(checkConnection);