JSFiddle - React, Tailwind, and code Playground

by somekittens

HTML

<!--contents of PHP file
<?php
echo $_GET["serviceName"];
?>
-->

JavaScript

function click(service){
    console.log(service);
    console.log(ajaxFunction(service));
}

function ajaxFunction(service){
    var ajaxRequest;
    
    try{
        //Opera 8.0+, Firefox, Safari, Chrome
        ajaxRequest = new XMLHttpRequest();
    }catch(e){
        //Internet Explorer
        try{
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
            try{
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e){
                //something went wrong
                alert("your browser broke!");
                return false;
            }
        }
    }
    //Create a function that will receive data sent from the server
    ajaxRequest.onreadystatechange = function(){
        if(ajaxRequest.readyState == 4){
            return ajaxRequest.responseText;
        }
    }
    ajaxRequest.open("GET","serverTime.php?serviceName="+service, true)
    ajaxRequest.send(null);
}