JSFiddle - React, Tailwind, and code Playground
HTML
<div id ="test"></div>
JavaScript
function load_file(file, id){
var xmlhttp;
if (XMLHttpRequest)
xmlhttp = new XMLHttpRequest;
else
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
document.getElementById(id).innerHTML =
xmlhttp.responseText;
}
xmlhttp.open('GET', file);
xmlhttp.send(data);
}
function get_json(method, file, callback, data){
var xmlhttp;
if (XMLHttpRequest)
xmlhttp = new XMLHttpRequest;
else
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
callback(JSON.parse(xmlhttp.responseText));
}
xmlhttp.open(method, file);
xmlhttp.send(data);
}
get_json('POST', '/echo/json/', function(data){
for(var i = 0; i < data.length; i++){
document.getElementById('test').innerHTML +=data[i] + '<br>';
}
// Ignore this line, it is used to create a test response from the server
}, 'json=' + encodeURIComponent('["x", 5, 30, 1000]'));