#home.php <script> function getRefresh() { $("#auto").show("slow"); $("#autoRefresh").load("bid.php", '', callback); } function callback() { $("#autoRefresh").fadeIn("slow"); setTimeout("getRefresh();", 1000); } $(document).ready(getRefresh); </script> <TR> <TD height="44" colspan="2" align=center class=txt_main><p><div id="autoRefresh"></div></p> </TD> </TR> #bid.php <?php session_start(); $arr_projects=mysql_fetch_array(mysql_query("SELECT * FROM `project` WHERE id='".$_SESSION['bid']."'")); if($arr_projects['close']!=1){ function secondsTime($examTime){ $time = explode(":", $examTime); $h = $time[0]*3600; $m = $time[1]*60; $s = $time[2]*1; $seconds = $h+$m+$s; return $seconds; //แปลงค่าเป็นวินาที } $seconds = secondsTime($arr_projects["times1"].":".$arr_projects["times2"].":0"); if (!isset($_SESSION['timeend'])){ unset($_SESSION['timeend']); $endtime = time() + $seconds; $_SESSION['timeend'] = $endtime; } ($_SESSION['timeend'] - time()) < 0 ? $EndTime = 0 : $EndTime = $_SESSION['timeend'] - time(); if($EndTime <= 0) { unset($_SESSION['timeend']); //session_destroy(); } รบกวนสอบถามพี่ๆ คะ ใช้ .load แล้วเรียก div มาซ้อนไม่ได้หรอคะ คือเพจ bid.php ไม่แสดงค่านะคะ แต่ถ้าเรียก bid.php ตรงๆ สามารถรันได้ปกติ รบกวนด้วยคะพี่ๆ แบบนี้ต้องปรับยังไงหรอคะ function checkTime($seconds){ $hours = floor($seconds / 3600); $mins = floor(($seconds - ($hours*3600)) / 60); $secs = floor(($seconds - ($hours*3600)) % 60); $time = $hours.":".$mins.":".$secs; return $time; //แปลงเป็นวินาทีให้อยู่ในรูปแบบ xx:xx:xx } $time = checkTime($EndTime); ?> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <body onLoad="begintimer()"> <script language=""> var limit="<?=$time;?>"; if (document.images){ var parselimit=limit.split(":") parselimit=(parselimit[0]*3600)+(parselimit[1]*60)+parselimit[2]*1 //alert(parselimit); } function begintimer(){ if (!document.images) return if (parselimit==1) // เหตุการณ์ที่ต้องการให้เกิดขึ้น // window.location='page.php'; ถ้าต้องการให้กระโดดไปยัง Page อื่น frmTest.submit(); else{ parselimit-=1 curhr=parseInt((parselimit%86400)/3600); curmin=parseInt((parselimit%86400)%3600/60); cursec=parseInt(((parselimit%86400)%3600)%60); if (curhr!==0 && curmin!=0) curtime="ระบบกำลังจะปิดประมูลภายใน <font color=red> "+curhr+"</font> ชั่วโมง <font color=red>"+curmin+" </font>นาที กับ <font color=red>"+cursec+" </font>วินาที " else if(cursec==1 && curmin==0 && curhr==0) { alert( "ระบบได้ทำการปิดประมูลเรียบร้อยแล้ว"); window.location = "close.php" } else { curtime="ระบบกำลังจะปิดประมูลภายใน <font color=red> "+curhr+"</font> ชั่วโมง <font color=red>"+curmin+" </font>นาที กับ <font color=red>"+cursec+" </font>วินาที "//โชว์นับ } document.getElementById('dplay').innerHTML = curtime; setTimeout("begintimer()",1000) } } //--> </script> <div id="dplay"></div> <form name="frmTest" action="close.php"> </form> <? } ?>
$(function(){ setInterval(function() { $("#autoRefresh").load("bid.php"); }, 1000); });
<script> $(document).ready(function(e){ $.ajax( url: 'bid.php').done( function( html ){ $("#autoRefresh").html( html ); $("#auto").show("slow"); }); </script>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง