日期:2014-05-16 浏览次数:20764 次
function Change_Select(){//当第一个下拉框的选项发生改变时调用该函数 var equipName = document.getElementById('equipName').value; var url = "SelectServlet?id="+ equipName; alert("url=" + url); if(window.XMLHttpRequest){ req = new XMLHttpRequest(); }else if(window.ActiveXObject){ req = new ActiveXObject("Microsoft.XMLHTTP"); } if(req){ //通过GET方法向指定的URL建立服务器的调用 req.open("GET",url,true); //指定回调函数为callback req.onreadystatechange = callback; req.send(null); } } function callback(){ if(req.readyState ==4){ [color=#FF0000]alert("req.status=" + req.status);[/color] if(req.status ==200){ parseMessage();//解析XML文档 }else{ alert("不能得到描述信息:" + req.statusText); } } } //解析返回xml的方法 function parseMessage(){ ...... } </script>
<servlet-mapping> <servlet-name>SelectServlet</servlet-name> <url-pattern>/SelectServlet</url-pattern> </servlet-mapping>