👍:0
You’ll need AJAX to run using interval:
setInterval(ajaxFunction(), 5000); // 5 sec
And in that function you have to call AJAX
function showHint(str) {
if (str.length == 0) { // case that doesn't call AJAX (can be discluded)
document.getElementById("txtHint").innerHTML = "";
return;
} else { // case that calls AJAX
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { //successfully getting answer
document.getElementById("txtHint").innerHTML = this.responseText; // this.responseText is answer you get
}
};
xmlhttp.open("GET", "gethint.php?q=" + str, true); // your php file that works with recieved data and echoes answer
xmlhttp.send();
}
}
AJAX part is just a random fragment from w3schools, if you are new to AJAX then just search for AJAX PHP