0
I wanted this code to just update a part of the site and not the whole site.
Because when I run the function on 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>
This code should update only the element with
id="ReloadThis"
, what’s going on?– Berriel
To begin I apologize Guilherme, then as I do only to update the div and not the whole page?
– Gonçalo