JSFiddle - React, Tailwind, and code Playground
by majidf
JavaScript
var currenttime;
function getDateInfo() {
var t = $.get("time.php?a=" + Math.random(), function(data) {
return data;
});
console.log(t); // when we get here the XMLHttpRequest is still in readyState=1, and there is no responseText yet
return t;
}
currenttime = getDateInfo();
setTimeout("alert(currenttime.responseText);", 3000); // when the alert is fired the XMLHttpRequest has been completed and readyState=4, and the responseText is displayed.