21,873
社区成员




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title> test </title>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
</head>
<body>
<table>
<tr>
<td>类型</td>
<td>总人数</td>
</tr>
<tr>
<td>学生</td>
<td id="student"></td>
</tr>
<tr>
<td>老师</td>
<td id="teacher"></td>
</tr>
</table>
<input type="button" name="b1" value="显示" onclick="show()">
<script type="text/javascript">
function show(){
$.post("server.php",{})
.done(function(data){
$('#student').html(data.student);
$('#teacher').html(data.teacher);
});
}
</script>
</body>
</html>
server.php
<?php
$ret = array(
'student' => 100,
'teacher' => 200
);
header('content-type:application:json;charset=utf8');
echo json_encode($ret);
?>
mysql 部分你可以自己写出,然后放入$ret便可。