Buongiorno ho trovato questo codice ma non funziona più ho provato a fare delle modifiche con esito negativo chiedo aiuto grazie
<script>
function getText() {
var $a = document.getElementById('text').value;
xhr = new XMLHttpRequest();
xhr.open('POST' , 'chatdb.php',true);
xhr.setRequestHeader('content-type','application/x-www-form-urlencoded');
xhr.send('chat='+$a);
xhr.onreadystatechange=function(){
if (xhr.responseText){
// document.getElementById('chatarea').innerHTML=xhr.responseText;
}
}
}
function setText(){
xhr = new XMLHttpRequest();
xhr.open('POST' , 'chatFetch.php' , true);
xhr.setRequestHeader('content-type','application/x-www-form-urlencoded');
xhr.send();
xhr.onreadystatechange = function(){
// alert(xhr.responseText);
document.getElementById('chatarea').innerHTML = xhr.responseText;
}
}
setInterval("setText()",2000);
setInterval("users()",3000);
function users(){
xhr1 = new XMLHttpRequest();
xhr1.open('POST' , 'userFetch.php' , true);
xhr1.setRequestHeader('content-type','application/x-www-form-urlencoded');
xhr1.send();
xhr1.onreadystatechange = function(){
// alert(xhr.responseText);
document.getElementById('loginperson').innerHTML = xhr1.responseText;
}
}
</script>