JSFiddle - React, Tailwind, and code Playground
HTML
<div>
Number to send: <input id="source" type="text" />
<button id="sendit" onclick="ChangeIt();">Send It</button>
</div>
<div>
Sent number: <input id="test1" type="text" />
</div>
JavaScript
function ChangeIt() {
alert('here');
var xmlhttp=false;
var response;
xmlhttp = new XMLHttpRequest();
var theSource = document.getElementById("source"),
val;
if(theSource) {
val = theSource.value;
alert(val);
}
xmlhttp.open("GET", "/ajax_json_echo/?x=" + val,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
response = new Function("return " + xmlhttp.responseText)();
//alert(xmlhttp.responseText);
//alert(response.get_response.x);
var theText = document.getElementById("test1");
if(theText) {
theText.value = response.get_response.x;
} else {
alert('not found');
}
}
}
xmlhttp.send(null);
}