客户端:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<label>帐号:</label>
<input type="text" id="name">
<input type="submit" id="sub" value="查 询">
<p id="p">12</p>
</body>
</html>
<script type="text/javascript">
var xml = new XMLHttpRequest();
var sub = document.getElementById('sub');
sub.onclick = function ()
{
xml.open('GET','1.php?name=131',true);
xml.send();
alert(xml.readyState);
alert(xml.responseText);
document.getElementById('p').innerHTML=xml.responseXML;
}
</script>
服务端:
<?php
$db = mysqli_connect("localhost","root","root","bigo");
$name = $_GET['name'];
$sql = "select * from bigo_yh where name='$name'";
$my = mysqli_query($db,$sql);
$bow = mysqli_num_rows($my);
if(!$bow<1)
{
while ($row = mysqli_fetch_assoc($my))
{
echo $row['name'];
}
}else{
echo "没有$name";
}
?>
xml.readyState返回的是1,
xml.responseXML没有数据。
为什么,那做错了
李晓健
慕的地6079101
Lawleit
qq_F_71
qq_歲月靜好不忘初心_0
慕粉4246601
Dikuni
田心枫
相关分类