function loadMyitem(output, counter, msg, FileQuery) {
//alert(output)
if( window.XMLHttpRequest )
{
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 1) {
msg.style.display = 'block';
msg.innerHTML = "";
} else if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
msg.style.display = 'block';
msg.innerHTML = "";
var respStr = new Array();
respStr = xmlhttp.responseText.split('|');
optStr = output.split('|');
var CC1 = $(counter).val();
for (i = 0; i < respStr.length; i++) {
//alert(respStr[i]);
document.getElementById(optStr[i] + CC1).value = respStr[i];
}
}
}
//document.getElementByID(msg).innerHTML=inputText;
xmlhttp.open("get", FileQuery, true);
xmlhttp.send();
}
这适用于Firefox,但是当我在chrome或opera中执行此函数时,它会给出错误:
未捕获的TypeError:无法设置属性&#39;显示&#39;未定义的
这个功能有什么问题?
答案 0 :(得分:0)
假设msg
是一个带有元素ID的字符串,请尝试此...
var msgElement = document.getElementById(msg);
if (msgElement) {
msgElement.style.display = 'block';
// and so on
}