私はこのhtmlとajaxファイルを持っていますが、私が望むように毎秒更新されていません。毎秒 getTime() を呼び出す必要があります。一度だけ実行し、その後は何もしません。
何かご意見は?ありがとう。
<head>
<title>Auction</title>
<script type="text/javascript">
function getTime() {
if (str=="") {
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","functions.php?action=getCurrentTime&id=13",true);
xmlhttp.send();
setTimeout(getTime, 1000);
}
window.setInterval(getTime, 1000);
</script>
</head>
<body>
<?php beginGetAllInfo(); ?>
</body>