用ajax写了个程序,不知道哪里错了?求高手之路
html代码是:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
?function get(zip){
? var aa=new XMLHttpRequest();
aa.onreadystatechange=function (){
if(aa.readyState==4){
var result=aa.responseText;
var number=result.plit(',');
document.getElementById("number1").value=number[0];
document.getElementById("number2").value=number[1];
}
}
aa.open("GET","getnumber.php?zip=" + zip);
aa.send(null);
}
</script>
</head>
<body>
<h2 align="center">地区邮政编码选择</h2>
<form action="">
城市:
<input type="text" id="city" size="20" onblur="get(this.value)"/>?
邮政编码:
<input type="text" id="number1" size="20"/>
区号:
<input type="text" id="number2" size="20"/>
</body>
php代码是:
<body>
<?php
$city=array("西安"=>"710000,029","辽源"=>"136200,0437","牡丹江"=>"157000,0453",
"重庆"=>"404100,023","上海"=>"200000,021","成都"=>"610000,028",
"贵阳"=>"550000,0851","北京"=>"100000,010","安康"=>"725000,0915",
"江津"=>"402200,023","舟山"=>"316000,0580","庆阳"=>"745000,0934",);
$zip=$_GET["zip"];
if((array_key_exists($zip,$city))
print $city[$zip];
else
print"、";
?>
</body>
总是提示“拒绝访问,html代码aa.open("GET","getnumber.php?zip=" + zip);有问题”
------解决方案--------------------
if(aa.readyState==4 && aa.status==200)
aa.open("GET","getnumber.php?zip=" + zip,true);