日期:2014-05-17  浏览次数:20580 次

为什么会出现警告??
var xmlhttp;
function $(id){
return document.getElementById(id);
}
function createXmlHttpRequest(){
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e1) {
try {
xmlhttp = new XMLHttpRequest();
if(xmlhttp.overrideMimeType){
xmlhttp.overrideMimeType("text/xml");
}
} catch (e2) {
}
}
}
}
function update(bid,price){
createXmlHttpRequest();
var count = $("count").value;
var url = "Modify?bid="+bid+"&count="+count+"&price="+price;

xmlhttp.open("post", url, true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4){
if(xmlhttp.status == 200){
var str = xmlhttp.responseText;
var price = $("price").value;
var t_price = count*price;
total.innerHTML = ""+t_price+"";
}
}
}这个地方会出现警告(就旁边这个中括号)。不知道为什么?
xmlhttp.send(null);
}

------解决方案--------------------
这样不报错了。

JScript code
var xmlhttp;
function $(id){
    return document.getElementById(id);
}
function createXmlHttpRequest(){
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e1) {
            try {
                xmlhttp = new XMLHttpRequest();
                if(xmlhttp.overrideMimeType){
                    xmlhttp.overrideMimeType("text/xml");
                }
            } catch (e2) {
            }
        }
    }
}
function update(bid,price){
    createXmlHttpRequest();
    var count = $("count").value;
    var url = "Modify?bid="+bid+"&count="+count+"&price="+price;

    xmlhttp.open("post", url, true);
    xmlhttp.onreadystatechange = function(){
        if(xmlhttp.readyState == 4){
            if(xmlhttp.status == 200){
                var str = xmlhttp.responseText;
                var price = $("price").value;
                var t_price = count*price;
                total.innerHTML = ""+t_price+"";
            }
        }
    }
    xmlhttp.send(null);
}