salve ,
ho il seguente codice, che non fa altro che leggere il contenuto di gestisci.php
function createObject() {
var tipo_richiesta;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
tipo_richiesta = new ActiveXObject("Microsoft.XMLHTTP");
}else{
tipo_richiesta = new XMLHttpRequest();
}
return tipo_richiesta;
}
var http = createObject();
function inviadati(valore1,valore2,operazione) {
http.open('get', 'gestisci.php');
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
document.getElementById('dati').innerHTML = response;
}
}
ecco gestisci.php
Io vorrei tanto che , appena il file text.php sia aggiornato (con l'aggiunta di contenuto tramite un altro script ajax che ho già fatto ma penso che ora non interessa),venga visualizzato il nuovo record...insomma, una semplice chat. Io ho pensato di far eseguire il codice ajax sopra postato ogni tot di tempo, esisterebbe una soluzione migliore?Codice PHP:$file=fopen("text.txt","a+");
$dim_file=filesize("text.txt");
$mess=fread($file,$dim_file);
print $mess;
fclose($file);
grazie a tutti

