参考代码:
//企业类别级联 function getCatalog(){ var name=document.getElementById("Lcata").value; var selectObj=document.getElementById("scata"); selectObj.options.length =0; $.ajax({ type:"POST", url: "/YHPC/getCata.action?name="+name+"&random="+Math.random()+"&way=ajax",//获取数据的函数 dataType:"xml", async:false, dataFilter:function(e){ if(e=='sessionOut'){ location.href="login.jsp"; return false; } var obj= eval(e); selectObj.removeAttribute("Option"); for(var i=0;i<obj.length;i++){ selectObj.options[selectObj.length] = new Option(obj[i][1], obj[i][0]); } } }); }