再用ajax做级联时 javascript中的req.status 不等于200 不往相应servlet中跳
function Change_Select() {var zhi=document.getElementById('country.id').value; alert(zhi);
// var url="/select?id="+escape(zhi);
// alert(url);
if(window.XMLHttpRequest) {
req=new XMLHttpRequest();
}else if(window.ActiveXObject)
{ req=new ActiveXObject("Microsoft.XMLHTTP"); }
if(req) { req.open("GET","http://localhost:8080/select",true); req.onreadystatechange=callback;
req.send(null); alert("+++++++++++++++++++++++++++++"); }
}
function callback() { if(req.readyState == 4) { if(req.status == 200) { 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('province.id'); 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.options.add(option); }catch(e){ } } } </SCRIPT> web,xml已经配置好 但是不往相应的servlet中去 req.status 不等于200 会有个提示Not able to retrieve description Not Found