这是json.html
<br> function _GetData()<br> {<br> var sid=$("#sid").val(); //jQ获取用户输入的值<br> $.ajax(<br> {<br> type:"POST",<br> url:"json.php",<br> data:{"stu_id":sid},<br> cache:false,<br> dataType:"json",<br> success:function(msn)<br> {<br> var content="<table align='center'><tr><td><strong>id</strong></td><td><strong>姓名</strong></td><td><strong>专业</strong></td><td><strong>电话</strong></td><td><strong>学号</strong></td></tr>";<br> $.each(msn,function(i)<br> {content+="<tr style='background-color:#ADD8E6;' ><td>"+msn[i][0]+"</td><td>"+msn[i][1]+"</td><td>"+msn[i][2]+"</td><td>"+msn[i][3]+"</td><td>"+msn[i][4]+"</td></tr>";<br> } );<br> content+="</table>";<br> $("#test").html(content);<br> }<br> });<br> }<br>
这是json.php
$sid=$_POST["sid"];
include 'comm.php'; //连接数据库
$sql = "select * from stu where stu_id={$sid}";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$arr[] = $row;
}
echo json_encode($arr);
输入的数据不能通过ajax传到php页面处理!