Have you tried the setInterval() javascript function?
It will automatically execute your code in a specified time(in milliseconds).
Usage:
setInterval( [you code or function call][, time interval in milliseconds] );
this will take care of updating your page via ajax without the need for user interaction.
Instead of calling your custom function in the onload event, you can try this:
<script type="text/javascript">
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","xxxxxx.php?q="+str,true);
xmlhttp.send();
}
setInterval('showUser()',10000);
setInterval(function(){ showUser();}, 10000);
</script>