JSFiddle - React, Tailwind, and code Playground

by Ashish Kasama

HTML

<form name='aaa' onsubmit="return refresh('aaa','"+document.URL+"', '', 'send');" method='post'>txt:
<input type='text' name='txt' autofocus='autofocus'>
<input type='submit' value=' send '>
</form>
<div id='aaa'>div that <b>*send*</b> txt to sql</div>

JavaScript

function refresh(name, url, info, type) {
    var str;
    if (type == "send") {
        str = document.forms["aaa"]["txt"].value;
    }
    if (type == "send" && str == "") {
        document.getElementById(name).innerHTML = "";
        return;
    }
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    } else { // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    var xhr = new XMLHttpRequest();
    xhr.open("GET", url + "?info=" + str, true);
    xhr.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
            //document.getElementById(name).innerHTML = this.responseText;
        }
    };
    xhr.send();
    return false;
}