jQuery 的新功能。这是我到目前为止所拥有的 - 基本上,我希望 jQuery+ajax 获取某个项目的最新日期。脚本每 1 秒刷新一次。
这是脚本:
<script>
var auto_refresh = setInterval(
function()
{
$.ajax({
type: "POST",
url: "gettime.php",
data: ({i : <?=$itemid;?>}),
function(data){
var s = data;
}
});
var t = s.split(/[- :]/); //split time from mysql
var d = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
$('#defaultCountdown').countdown({until: d,compact: true,
description: ''});
}, 1000);
</script>
这是gettime.php
<?php
include("inc/dblink.inc");
$itemid = intval($_POST['i']);
$row = mysql_fetch_array(mysql_query("SELECT * FROM test WHERE itemid='$itemid' ORDER BY bidid DESC LIMIT 0,1"));
$date = $row['date'];
echo $date; //sample date is 2012-04-13 10:03:37
?>