php 页面
header ( 'content-type:text/html;charset=utf-8' );
$mysqli = new mysqli ( 'localhost', 'root', '', 'java' );
if ($mysqli->connect_errno) {
die ( 'CONNECT ERROR:' . $mysqli->connect_error );
}
$mysqli->set_charset ( 'utf8' );
$sql = "select kd,sum from kd";
$mysqli_result = $mysqli->query ( $sql );
$rows = array ();
while ( $row = $mysqli_result->fetch_assoc () ) {
$rows [] = $row;
}
echo json_encode ( $rows );
html 页面
刷新$(function() {
updateMsg();
});
function updateMsg() {
$.post("getData.php", {
}, function(json) {
var arr=eval(json);
var tr=null;
for(var i=0;i
tr+="
"+"
"+arr[i].kd+""+"
"+arr[i].sum+""+"
";}
$("#datatotable").html(tr);
setTimeout('updateMsg()', 60000);
});
}