日期:2014-05-16  浏览次数:20652 次

调试了一个星期苦逼ajax,除了IE其它均能获取数据,求高人!
不多说了,直接上源码,高手们帮帮我这只笨鸟吧,就只有IE不能显示,坑爹的。功能是类似那种省市联动
HTML code
<script>
function ajax(){
    val = document.getElementById("Sort_One").value 
    var xmlhttp;
    if (window.XMLHttpRequest){
        xmlhttp=new XMLHttpRequest();
    }
    else{
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    xmlhttp.onreadystatechange=function(){
        if (xmlhttp.readyState==4 && xmlhttp.status==200){
            document.getElementById("SortOne").innerHTML=xmlhttp.responseText;
        }
    }
xmlhttp.open("GET","ajax.asp?t="+Math.random()+"&val="+val,true);
xmlhttp.send();
//xmlhttp.open("POST","ajax.asp",true)
//xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
//xmlhttp.send("val="+val+"&t="+Math.random());
}
</script>



HTML code
    
        val = request("val")

    sortone_sql = "select * from Phone_SortOne where Content_Sort_ID="&val

    set query_SortOne = Conn.execute("select * from Phone_SortOne where Content_Sort_ID="&val)
    while not query_SortOne.eof
        response.write "<option>"&query_SortOne("Content_SortOne_Name")&"</option>"
        query_SortOne.movenext
    wend


------解决方案--------------------
楼主看看这个例子 就知道 你做的在ie下无效果的原因了
在ff 和 ie 下对比看
HTML code

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="gb2312" />
        <title></title>    
        <style>
        </style>        
    </head>
    <body>
        <select id="test"></select>
        <script>
            function $(el){
                return typeof el == 'string' ? document.getElementById(el) : el;
            }
            $('test').innerHTML = '<option>1</option>'
        </script>
    </body>
</html>

------解决方案--------------------
这是IE 的一个BUG,微软的BUG申明中注明了两种解决方案: 
1. 如果您必须使用 innerHTML ,一种替代方法是使用一个 div 对象封装 SELECT 元素和然后设置 div 对象的 innerHTML 属性。
如:
HTML code

<div id="div1">
<select id="sel1" ></select>
</div>
<script>
window.onload=function(){
    document.getElementById("div1").innerHTML="<select id='sel1'><option>a</option></select>";
}
</script>

2、使用new Option()对象,然后添加到下拉框控件中。
推荐使用这种。

------解决方案--------------------
兼容问题 汗~
 1楼说的好!