dnzm518 发表于 2007-8-4 18:00

[求助]AJAX 无刷新菜单问题 急!~~

<P>大家帮忙看看为什么不行,老有错误,而且,也老写空值<BR>-------JS 代码------------<BR>var xmlhttp=false;<BR>try{<BR>    xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");<BR>}catch(e){<BR>    try{<BR>        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");<BR>    }catch(e2){<BR>        xmlhttp=false;<BR>    }<BR>}<BR>if (!xmlhttp &amp;&amp; typeof XMLHttpRequest != 'undefined'){<BR>    xmlhttp=new XMLHttpRequest();<BR>}<BR>function startRequest(){<BR>    document.getElementById("class2").options.length=0;<BR>    var url=document.f1.class1.value;<BR>    var qurl="select_class.php?class1="+url;<BR>    xmlhttp.open("GET",qurl,true);<BR>    xmlhttp.send(null);<BR>    xmlhttp.onreadystatechange=function(){<BR>        if (xmlhttp.readyState==4){<BR>            if (xmlhttp.status==200){<BR>                var obj=document.getElementById("class2");<BR>                eval(xmlhttp.responseText);<BR>            }<BR>        }<BR>    }<BR>}<BR>--------HTML 代码-----------<BR>信息类别:&lt;select name="class1" id="input_3" onChange="startRequest();"&gt;&lt;option value="0" selected&gt;信息类别&lt;/option&gt;&lt;?php op_class1();?&gt;&lt;/select&gt; &amp;nbsp;<BR>信息分类:&lt;select name="class2" id="class2"&gt;&lt;option value="0"&gt;信息分类&lt;/option&gt;&lt;/select&gt;<BR>------------select_class.php文件代码------------<BR>$class1=$_GET['class1']<BR>if(isset($class1)){<BR>    $rs=mysql_query("select * from class where f_classid=$class1");<BR>    while($row=mysql_fetch_array($rs)){<BR>        echo "obj.options[obj.options.length]=new Option('$row[1]','$row[0]');n";<BR>    }<BR>}<BR></P>
<P>请大家帮忙看看,急!!~~,在这里谢谢了</P>


页: [1]

编程论坛