<script language="javascript">
function GetResult()
{
http_request = false;
//开始初始化XMLHttpRequest 对象
if(window.XMLHttpRequest) { //Mozilla 浏览器
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {//设置MiME 类别
http_request.overrideMimeType("text/xml");
}
}
else if (window.ActiveXObject) { // IE 浏览器
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) { // 异常,创建对象实例失败
window.alert("不能创建XMLHttpRequest 对象实例.");
return false;
}
// 处理返回信息的函数
function processRequest() {
if (http_request.readyState == 4) { // 判断对象状态
if (http_request.status == 200) { // 信息已经成功返回,开始处理信息
alert(http_request.responseText);
} else { //页面不正常
alert("您所请求的页面有异常。");
}
}
}
http_request.onreadystatechange = processRequest;
http_request.open("POST","browse.jsp",false);
http_request.send(); //服务器端处理返回的是经过escape编码的字符串.
var strResult = unescape(http_request.responseText); //将字符串分开.
var arrResult = strResult.split("###");
RemoveRow(); //删除以前的数据.
//将取得的字符串分开,并写入表格中.
for(var i=0;i<arrResult.length;i++)
{
arrTmp = arrResult[i].split("@@@");
id = arrTmp[0]; //字段id的值
menu2 = arrTmp[1]; //字段menu的值
text = arrTmp[2]; //字段text的值
row1 = tb.insertRow();
cell1 = row1.insertCell();
cell1.innerText = id;
cell2 = row1.insertCell();
cell2.innerText = menu2;
cell3 = row1.insertCell();
cell3.innerText = text;
}
}
function RemoveRow(){
//保留第一行表头,其余数据均删除.
var iRows = tb.rows.length;
for (var i=0;i<iRows-1;i++) {tb.deleteRow(1);}
}
function window_onload()
{
//在2秒后调用GetResult函数
timer = window.setInterval("GetResult()",2000);
}
</script>
以上JS在IE运行正常,在Firefox下报错如下:
uncaught exception: [Exception... "Not enough arguments [nsIXMLHttpRequest.send]" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://127.0.0.1:8080/xml/browse.htm :: GetResult :: line 39" data: no]
要怎么修改呢?