I wanted this code to only update one part of the site and not the whole site.
Because when I run the function in a div, it updates the whole site.
<script type="text/javascript">
function Ajax(){
var xmlHttp;
try { xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari }
catch (e){
try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer }
catch (e){
try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e){
alert("No AJAX!?");
return false;
}
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
document.getElementById('ReloadThis').innerHTML=xmlHttp.responseText;
setTimeout('Ajax()',10);
}
}
xmlHttp.open("GET","index.php",true); // aqui configuramos o arquivo
xmlHttp.send(null);
}
window.onload=function(){
setTimeout('Ajax()',10); // aqui o tempo entre uma atualização e outra
}
</script>