<script type="text/javascript">
var t;
function tick() {
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200 && document.getElementById("txtHint").innerHTML!=xmlhttp.responseText) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
};
xmlhttp.open("GET","http://ubarskit.com/v/response.php",true);
xmlhttp.send();
t=setTimeout("tick()",1000);
}
</script>
</head>
<body onload="tick()">
<span id="txtHint"></span>
</body>
I want it to update the text in the span-tag from response.php every second. Works in chrome, but not in Firefox or Opera.
Here's the response.php file:
<?php
if(isset($_GET['ropa']))
{
$fp = fopen('shout.txt', w);
fwrite($fp, $_GET['ropa']);
fclose($fp);
}
else
{
echo file_get_contents('shout.txt');
}
?>