JSFiddle - React, Tailwind, and code Playground

HTML

<textarea cols="100" id="responseArea"></textarea>

JavaScript

$(document).ready(function() {
    try {
        $('#responseArea').val(webCall("http://www.google.com", "GET", null));
    } catch (err) {
        window.alert("Caught an error: " + err);   
    }
});

var webResponse = null;

function webCall(action, type, xmlBodyString) {
    console.log("In webCall with " + type + ": " + action);
    webResponse = null;
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4)
        {
            if (xmlhttp.status == 200) {
                webResponse = xmlhttp.responseXML;
            } else {
                var statusTxt = xmlhttp.statusText;
                if (statusTxt == null || statusTxt.length == 0) {
                    statusTxt = "An Unknown Error Occurred";
                }
                throw "ERROR " + xmlhttp.status + ":" + statusTxt;
            }
        }
    }
    xmlhttp.open(type, action, true);
    if (xmlBodyString == null) {
        xmlhttp.send();
    } else {
        xmlhttp.setRequestHeader("Content-Type", "text/xml");
        xmlhttp.send(xmlBodyString);
    }
    for (var i = 0; i < 20; i++) {
        if (webResponse != null) {
            break;
        }
        window.setTimeout(nop, 250);
    }
    if (webResponse == null) {
        throw "Waited 5 seconds for a response, and didn't get one.";
    }
    console.log("Responding with " + webResponse);
    return webResponse;
}

function nop() {

}