JSFiddle - React, Tailwind, and code Playground
HTML
<div id='content'></div>
JavaScript
var PreloadIt = new Image(441,291);
PreloadIt.src="http://www.titleist.com/images/products/ball_fitting/ajax-loading.gif";
var http = new XMLHttpRequest();
var url = "/echo/html/";
var params = "html=Response&delay=3";
http.open("POST", url, true);
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200) {
document.getElementById('content').removeChild(document.getElementById('ajaxloader'));
document.getElementById('content').innerHTML = http.responseText
}
}
function BeginLoading(){
var eLoader = document.createElement("img");
eLoader.src = "http://www.titleist.com/images/products/ball_fitting/ajax-loading.gif";
eLoader.alt = "";
eLoader.setAttribute('width', "25%");
eLoader.setAttribute('height', "25%");
eLoader.id = "ajaxloader"
document.getElementById('content').appendChild(eLoader);
http.send(params);
}
BeginLoading()