It is better if you switched these two lines.
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("POST",url,true)
It really does not matter in your case, but it is better practice to do so
well there is a few thing syou can do. Easiest thing you can do is add a div to your page and maybe use an activity indicator:
http://www.webscriptlab.com/index.php
Code:
<div id="loadingMsg" style="display:none;position: absolute;background-color:#CCC;width:200px; height:200px;text-align:center;top:100;left:100">Loading Please Wait</div>
Before the open statement you show the div
Code:
document.getElementById("loadingMsg").style.display = "block";
xmlHttp.open("POST",url,true)
and hide it when the response is back
Code:
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("loadingMsg").style.display = "none";
if(xmlHttp.status == 200)
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
else
{
alert("Error reading data");
}
}
}
Hope that helps
Eric