Ti ringrazio del suggerimento
ma in questo modo viene richiamata
una volta sola.
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="JavaScript" type="text/javascript">
var time = 2000;
var page = "query.php";
//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
var receiveReq=false; //Clear our fetching variable
try {
receiveReq = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
} catch (e) {
try {
receiveReq = new ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
} catch (e) {
receiveReq = false;
}
}
if (!receiveReq && typeof XMLHttpRequest!='undefined') {
receiveReq = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
}
return receiveReq;
}
//Get our browser specific XmlHttpRequest object.
var receiveReq = getXmlHttpRequestObject();
//Initiate the asyncronous request.
function getQuery() {
//If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call.
if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
//Setup the connection as a GET call to SayHello.html.
//True explicity sets the request to asyncronous (default).
receiveReq.open('GET', page , true);
//Set the function that will be called when the XmlHttpRequest objects state changes.
receiveReq.onreadystatechange = handlegetQuery;
//Make the actual request.
alert("pippo");
receiveReq.send(null);
}
}
//Called every time our XmlHttpRequest objects state changes.
function handlegetQuery() {
//Check to see if the XmlHttpRequests state is finished.
if (receiveReq.readyState == 4) {
//Set the contents of our span element to the result of the asyncronous call.
var content = receiveReq.responseText;
document.getElementById('news').innerHTML = content;
}
}
window.onload = function()
{
window.setTimeout("getQuery()", 1000); ;
}
</script>
</head>
<body>
<p id="news"></p>
</body>
</html>
L'intento sarebbe ottenere una sorta di 'refresh'
(mi sto chiedendo se sia possible una cosa del genere
e dove sto facendo uno sbaglio a livello concettuale)
Detto in due parole apro la pagina e se ad esempio l'ammistratore
del DB o chi per lui effettua un INSERT o un UPDATE senza
effettuare nessun tipo di operazione (lascio la finestra aperta)
vedere questi INSERT o UPDATE una sorta di real time.
Spero di essermi spiegato meglio.
Fammi sapere.