 |
|
พอดี ทำโปรเจค เกี่ยวกับการประมูลค่ะ นับเวลาเป็นวินาที
ประมาณเว็บนี้ค่ะ http://bidleaders.com/ จะนับเวลาถอยหลังทุก ๆ 2 นาที(หากมีผู้มาประมูลใหม่) โดย อิงเวลาจาก server
จะทำเวลา countdown ค่ะ เหมือนเว็บข้างต้น
ต้องทำยังไงค่ะ ลองใช้ ajax ดู แต่ยังทำเวลานับถอยหลัง โดยการกำหนดค่าเวลายังไม่ได้ค่ะ
ช่วยดูหน่อยนะค่ะ
test.html
<html>
<head>
<script language=JavaScript>
var xmlhttp
function Inint_AJAX () {
var xmlhttp = false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
xmlhttp = false;
}
}
if(!xmlhttp && document.createElement){
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function startCallback() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
document.getElementById("time").innerHTML=xmlhttp.responseText; //รับค่ากลับมา
delete xmlhttp;
setTimeout("doStart()", 1000);
}
}
}
function doStart() {
xmlhttp = Inint_AJAX();
var url = "time.php";
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = startCallback;
xmlhttp.send(null);
}
</script>
</head>
<body>
<div id="time"> </div>
<script language=JavaScript>doStart();</script>
</body>
</html>
time.php
<?
$mtime= date("s",mktime(0,0,0,0,0,0) - time());
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
header("content-type: application/x-javascript; charset=tis-620");
echo "$mtime";
?>
รบกวนผู้รู้ ช่วยดู หน่อยค่ะ ด่วนมาก
ใครพอมีแนวทางหรือตัวอย่าง ช่วยด้วยนะค่ะ
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
2009-03-03 00:17:15 |
By :
kookkik |
View :
1777 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |