急~!!struts +ajax 级联菜单.问题~!盼各位大侠帮帮忙~!
request.responseXML.documentElement;返回null问题~!!!!
具体如下:
显示页面:
<SCRIPT type="text/javascript">
var req;
window.onload=function(){
}
function Change_Select()
{
var zhi=document.getElementById('province').value;
var url="/teach/aaa.do?method=g1&id="+zhi;
// alert(url);
if(zhi==""){
alert("请选择您要察看的信息");
return;
}else{
if(window.XMLHttpRequest)
{
req=new XMLHttpRequest();
}else if(window.ActiveXObject)
{ try{
req=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
try{
}catch(e){
req=new ActiveXObject("Msxml2.XMLHTTP");
}
}
}
if(req)
{
req.open("GET",url,true);
req.onreadystatechange=callback;
req.send(null);
}
}
}
function callback()
{
if(req.readyState == 4)
{
if(req.status == 200)
{
var xmlDoc=req.responseXML.documentElement;
alert(xmlDoc);
parseMessage();
}else{
alert("Not able to retrieve description : "+req.statusText);
}
}
}
function parseMessage()
{
var xmlDoc=req.responseXML.documentElement;
var xSel=xmlDoc.getElementsByTagName('select');
var select_root=document.getElementById('city');
select_root.options.length=0;
for(var i=0;i<xSel.length;i++)
{
var xValue=xSel[i].childNodes[0].firstChild.nodeValue;
var xText=xSel[i].childNodes[1].firstChild.nodeValue;
var option=new Option(xText,xValue);
try{
select_root.add(option);
}catch(e){
}
}
}
<td height="29" width="30%">
<bean:message key="LoginForm.sheng"/>
<html:select property="province" onchange="Change_Select()">
<html:option value="">--</html:option>
<html:options collection="provinceid" property="value" labelProperty="label"/>
</html:select>
</td>
<td width="30%" id="mycity">
<html:select property="city">
<html:option value="">---</html:option>
</html:select>
</td>