本帖最后由 yczhaoliao 于 2012-09-25 19:36:52 编辑
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);
}
回复讨论(解决方案)
这样不报错了。
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);}
Salin selepas log masuk
楼主先把格式整理一下吧,这样方便别人阅读,也方便自己找错