ajax +php 二级联动菜单代码 <br /> var http_request=false;<br /> function send_request(url){//初始化,指定处理函数,发送请求的函数<br /> http_request=false;<br /> //开始初始化XMLHttpRequest对象<br /> if(window.XMLHttpRequest){//Mozilla浏览器<br /> http_request=new XMLHttpRequest();<br /> if(http_request.overrideMimeType){//设置MIME类别<br /> http_request.overrideMimeType("text/xml");<br /> }<br /> }<br /> else if(window.ActiveXObject){//IE浏览器<br /> try{<br /> http_request=new ActiveXObject("Msxml2.XMLHttp");<br /> }catch(e){<br /> try{<br /> http_request=new ActiveXobject("Microsoft.XMLHttp");<br /> }catch(e){}<br /> }<br /> }<br /> if(!http_request){//异常,创建对象实例失败<br /> window.alert("创建XMLHttp对象失败!");<br /> return false;<br /> }<br /> http_request.onreadystatechange=processrequest;<br /> //确定发送请求方式,URL,及是否同步执行下段代码<br /> http_request.open("GET",url,true);<br /> http_request.send(null);<br /> }<br /> //处理返回信息的函数<br /> function processrequest(){<br /> if(http_request.readyState==4){//判断对象状态<br /> if(http_request.status==200){//信息已成功返回,开始处理信息<br /> document.getElementById(reobj).innerHTML=http_request.responseText;<br /> }<br /> else{//页面不正常<br /> alert("您所请求的页面不正常!");<br /> }<br /> }<br /> }<br /> function getclass(obj){<br /> var pid=document.form1.select1.value;<br /> document.getElementById(obj).innerHTML="<option>loading...";<br /> send_request('doclass.php?pid='+pid);<br /> reobj=obj;<br /> }<br /> <br /> ajax +php 浜