ajax+php无刷新二级联动菜单,为什么 xmlhttp.open("GET",url,true);//为什么老是报这行错误?谢谢
<html><head><title></title><scriptlanguage="javascript">varxmlhttp=null;functiongetxm...
<html>
<head>
<title></title>
<script language="javascript">
var xmlhttp = null;
function getxmlhttprequest()
{
var xmlhttp=null;
try
{
xmlhttp = new xmlhttprequest();
}
catch(e)
{
try
{
xmlhttp = new activexobject("msxml2.xmlhttp");
}
catch (e)
{
try
{
xmlhttp = new activexobject("microsoft.xmlhttp");
}
catch(e)
{
xmlhttp = false;
}
}
}
return xmlhttp;
}
function sendrequest()
{
var prov_name = document.getElementById("province").value;
if((prov_name == null) || (prov_name == ""))
return;
xmlhttp = getxmlhttprequest();
if(xmlhttp == null)
{
alert("浏览器不支持xmlhttprequest!");
return;
}
var url = "aaa.php";
qq = url + "?prov=" + prov_name;
xmlhttp.open("GET",url,true);//为什么老是报这行错误?
xmlhttp.onreadystatechange = updatepage;
xmlhttp.send(null);
}
function updatepage()
{
if(xmlhttp.readystate == 4 && xmlhttp.status == 200)
{
var response = xmlhttp.responsetext;
document.getElementById("city").innerhtml = response;
}
}
</script>
<head>
<body>
<form action="aaaa.php">
<div>
<select id="province" onchange="sendrequest()">
<option value="">请选择一个省(自治区)</option>
<option value="ah">安徽</option>
<option value="fj">福建</option>
<option value="gs">甘肃</option>
<option value="gd">广东</option>
<option value="gx">广西</option>
<option value="gz">贵州</option>
<option value="hn">海南</option>
<option value="hb">河北</option>
<option value="hh">河南</option>
<option value="hl">黑龙江</option>
</select>
</div>
</form>
<div id="city">
</div>
</body>
</html> 展开
<head>
<title></title>
<script language="javascript">
var xmlhttp = null;
function getxmlhttprequest()
{
var xmlhttp=null;
try
{
xmlhttp = new xmlhttprequest();
}
catch(e)
{
try
{
xmlhttp = new activexobject("msxml2.xmlhttp");
}
catch (e)
{
try
{
xmlhttp = new activexobject("microsoft.xmlhttp");
}
catch(e)
{
xmlhttp = false;
}
}
}
return xmlhttp;
}
function sendrequest()
{
var prov_name = document.getElementById("province").value;
if((prov_name == null) || (prov_name == ""))
return;
xmlhttp = getxmlhttprequest();
if(xmlhttp == null)
{
alert("浏览器不支持xmlhttprequest!");
return;
}
var url = "aaa.php";
qq = url + "?prov=" + prov_name;
xmlhttp.open("GET",url,true);//为什么老是报这行错误?
xmlhttp.onreadystatechange = updatepage;
xmlhttp.send(null);
}
function updatepage()
{
if(xmlhttp.readystate == 4 && xmlhttp.status == 200)
{
var response = xmlhttp.responsetext;
document.getElementById("city").innerhtml = response;
}
}
</script>
<head>
<body>
<form action="aaaa.php">
<div>
<select id="province" onchange="sendrequest()">
<option value="">请选择一个省(自治区)</option>
<option value="ah">安徽</option>
<option value="fj">福建</option>
<option value="gs">甘肃</option>
<option value="gd">广东</option>
<option value="gx">广西</option>
<option value="gz">贵州</option>
<option value="hn">海南</option>
<option value="hb">河北</option>
<option value="hh">河南</option>
<option value="hl">黑龙江</option>
</select>
</div>
</form>
<div id="city">
</div>
</body>
</html> 展开
1个回答
展开全部
报的什么错?
更多追问追答
追问
对象不支持此属性或方法, 行53 字符 9 我看了 就是 xmlhttp.open("GET",url,true);
http://www.111cn.net/phper/php/34274.htm 是从这个上摘下来的
追答
写法没错.把xmlhttp弹出来看看.它是不是一个object
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询