2 분마다 페이지를 새로 고침하여 PHP 파일이 실행되도록하여 데이터 테이블을 다시 채 웁니다. setTimeout()을 사용하여이 작업을 수행 할 수 있지만이 작업을 수행하는 방법을 알 수는 없다고 읽었습니다. 누구나 예제 코드가 있습니까?AJAX 시간 초과 MySQL 새로 고침
<script type="text/javascript">
function showSellers(isbn)
{
//if there is no isbn given, show nothing and return nothing
if (isbn=="")
{
document.getElementById("sellers").innerHTML="";
return;
}
//AJAX request for IE7+, Firefox, Chrome, Opera, Safari
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
//AJAX request for IE6, IE5
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
//if the state of the page changes, do this
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("sellers").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax_seller.php?isbn="+isbn,true);
xmlhttp.send();
}
</script>
jQuery를 사용하면 코드 크기를 약 5 줄까지 줄일 수 있습니다. –
어떻게? 기본적으로 2 분의 간격으로 테이블을 포함하는 특정 div를 새로 고치고 싶습니다. 볼 수있는 모든 예제는 버튼을 누르는 것과 같은 트리거가 필요합니다. –