JavaScript innerHTML不能用于IE吗?

use*_*373 6 html javascript xmlhttprequest

我正在使用ajax调用为我的下拉列表并将其分配给html,适用于mozilla nad crome,但对于IE它显示一个空白的下拉列表

var xmlhttp;

var strURL = "selectedu.php?selectward="+selectward;

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function(){
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
        if(xmlhttp.responseText=="NOER")
        {
            alert("Select ER Type");
        }
        else
        {
            document.getElementById(id).innerHTML=xmlhttp.responseText;
        }   
    }
}
xmlhttp.open("GET",strURL,true);
xmlhttp.send();
Run Code Online (Sandbox Code Playgroud)

Ric*_*lly 8

innerHTML尝试添加或更新表单元素时,该属性在IE中有一些问题,解决方法是创建一个div并在附加到DOM之前设置innerHtml属性:

var newdiv = document.createElement("div");
newdiv.innerHTML = xmlhttp.responseText;
var container = document.getElementById(id);
container.appendChild(newdiv);
Run Code Online (Sandbox Code Playgroud)