javascript 参考错误:未定义 xmlhttp
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20137051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 17:50:14 来源:igfitidea点击:
ReferenceError: xmlhttp is not defined
提问by I wrestled a bear once.
My AJAX is not working and I cannot figure out why. What am I missing??
我的 AJAX 不工作,我不知道为什么。我错过了什么??
ReferenceError: xmlhttp is not defined @ javascript.js:5
ReferenceError: xmlhttp 未定义@javascript.js:5
function insapts(pin){
if (window.XMLHttpRequest){ xmlhttpp=new XMLHttpRequest(); }else{ xmlhttpp=new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttpp.onreadystatechange=function(){
if(xmlhttpp.readyState==4 && xmlhttpp.status==200){
document.getElementById('apttimeins').innerHTML = xmlhttp.responseText;
}
}
var url = "bridge3.php?pin="+pin;
xmlhttpp.open("GET",url,false);
xmlhttpp.send(null);
}
回答by karthikr
You have a typo. The XMLHttpRequest
object is created with the local variable name xmlhttpp
.
你有一个错字。该XMLHttpRequest
对象是用局部变量名称创建的xmlhttpp
。
Change
改变
xmlhttp.responseText;
to
到
xmlhttpp.responseText;
// ^ missing p