Hello! I have written this test code:
Code:
<html>
<body>
<script type="text/javascript">
function ajaxFunction() {
var xmlHttp;
try { //Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
}
catch (e) {
try { //Internet Explorer
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
alert("Your browser does not support AJAX!");
return false;
}
}
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState==4) {
document.myForm.time.value = xmlHttp.responseText;
xmlHttp.responseText = "";
}
}
xmlHttp.open("get","time.php",true);
xmlHttp.send(null);
}
</script>
<form name="myForm">
Name: <input type="text" onkeyup="ajaxFunction();" name="username" />
Time: <input type="text" name="time" />
</form>
</body>
</html>
And in time.php:
Code:
<?php
echo date("H:i:s");
?>
And it works perfectly fine, the first time. But the second time and the rest of the times (after clearing the textboxes), the same time as before will continue to pop up, each time I release a key. But it should be the current time, not the same time as before!

I would really appreciate some help here. What in my code is wrong? Or is it IE 7 that troubles me?