日期:2014-05-16 浏览次数:20389 次
setInterval(function() {
var value1 = <?php echo db_value()?>;
var x = (new Date()).getTime(), // current time
y = value1;
series.addPoint([x, <?php echo db_value()?>], true, true);
alert(value1);
}, 1000);
<?php
function db_value()
{
include_once('connect.php');
$res = mysql_query("select value from date_data where id = (select max(id) from date_data)");
while($row = mysql_fetch_array($res)){
$value = $row[0];
//echo $value;
return $value;
}
}
?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<<script>
setInterval(function () {
$.ajax({ type: 'POST', url: 'xxx.php', dataType: 'text', success: function (value1) {
var x = (new Date()).getTime(), y = value1;
series.addPoint([x, value1], true, true);
alert(value1);
}
});
}, 1000);
</script>