日期:2014-05-17 浏览次数:20953 次
<script type="text/javascript">
//创建连接,判断浏览器
var http_request=false;
function createXMLHttpRequest(){
if(window.XMLHttpRequest){
XMLHttpReq=new XMLHttpRequest(); //创建对象对应不同的浏览器
}
else if(window.ActiveXObject){
try{
XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
}
}
}
}
//onchange事件
function changeProvice(){
var lou=document.getElementById("ss").value;
sendRequest("ldServlet?lou="+lou); }
//发送请求
function sendRequest(url){ createXMLHttpRequest();
XMLHttpReq.open("GET",url,true);
XMLHttpReq.onreadystatechange=progessRequest;
XMLHttpReq.send(null);
}
function progessRequest(){
if(XMLHttpReq.readyState==4){
if(XMLHttpReq.status==200) {
var xmlDoc1=XMLHttpReq.responseXML; //获取返回的XML文档
var fangs=xmlDoc1.getElementsByTagName("fang");//获取XML节点
var obj=document.getElementById("fang");//获取第二级菜单的对象
if(obj!=null){//如果不为空就置空
obj.options.length=0;
}
for(var i=0;i<fangs.length;i++){//用循环给select中加值
var xValue = fangs[i].childNodes[0].firstChild.nodeValue;
var xText = fangs[i].childNodes[1].firstChild.nodeValue;
var option = new Option(xText, xValue);
try{
obj.add(option);
}catch(e){}
}
}else{
alert( "请求异常"+XMLHttpReq.responseText);
}
}
}
</script>
function changeProvice(){
var lou=document.getElementById("ss").value;
sendRequest("ldServlet?lou="+lou); }
//发送请求
function sendRequest(url){ createXMLHttpRequest();
XMLHttpReq.open("GET",url,true);
XMLHttpReq.onreadystatechange=progessRequest;
XMLHttpReq.send(null);
}