function handleServerResponse() {
if (xmlhttp.readyState == 4) {
if(xmlhttp.status == 200) {
document.getElementById("message").innerHTML=xmlhttp.responseText;
}
else {
alert("Error during AJAX call. Please try again");
}
}
So the above is a part of the ajax code that returns a HTML and loads it into the div name message. All I want to do is to hide the div message after 5 seconds after this. I searched a lot but with no concrete answer. Can someone please help me.
You just need to kick off a
setTimeoutwith an inline function to hide themessagediv.The basic gist:
setTimeout(function() { /* do something */}, 5000); // Timeout in millisecondsCombined with your code: