Salve a tutti,
non riesco a risolvere un problema stupido con ajax...
Vi spiego:
Ho una pagina html che richiede dei dati ad una pagina php (azione.php) ogni due secondi..
questo è il codice:e questo è il codice della pagina php:codice:<script> function refreshDate(myUrl,myField){ var Field = document.getElementById(myField); // selects the given element if(window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera, Internet Explorer 7 } if(window.ActiveXObject) { try{ xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); // Internet Explorer 6 } catch(e) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer 4,5 } } xmlhttp.open("GET", myUrl+ '?rnd=' + Math.random(), true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState == 4) { Field.innerHTML = xmlhttp.responseText; // puts the result into the element } } xmlhttp.send(null); } </script> <body onLoad="refreshDate('azione.php','richieste');setInterval('refreshDate(\'azione.php\',\'richieste\');',2000);"> <p id="richieste"></p> </body>In teoria dovrei ricevere l'alert ogni due secondi...codice:<?php echo "ciao: ".time()." "; echo "<script>alert('funziona');</script>"; ?>
In pratica ricevo solo la scritta "ciao" + il tempo "time()"...
Perchè non mi funziona?
Grazie a tutti in anticipo!![]()