Home > Backend Development > PHP Tutorial > 一直揭示:xmlhttp is not defined

一直揭示:xmlhttp is not defined

WBOY
Release: 2016-06-13 13:10:13
Original
1990 people have browsed it

一直提示:xmlhttp is not defined
描述:在做一个公共聊天室的页面,在用户提交发言后,在公共讨论区显示发言。
talk.php文件中的提交代码:
 


其中还包含了:
 
 
js函数tk就是在main.js中定义的,代码为:
  function tk(form,maxtm){
if(form.cont.value==""){
alert("发言不允许为空!");
form.cont.focus();
return false
}
face = form.face.value;
color = form.color.value;
obt = form.obt.value;
cont = form.cont.value;
var url = "talk_chk.php?action=send&face="+face+"&color="+color+"&obt="+obt+"&cont="+cont;
xmlhttp.open("Get",url,true);
xmlhttp.onreadystatechange = callback;
xmlhttp.send(null);
form.cont.value="";
form.cont.focus();
refrsh(maxtm);
return false;
}
但是提交发言后,提示: xmlhttp is not defined !! 弄了一晚上了,跪求!!!!!!
xmlhttprequest.js中的代码:
  if(window.ActiveXObject){
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpReuqest){
xmlhttp = new XMLHttpRequest();
}

------解决方案--------------------
else if( window.XMLHttpReuqest )
这里错了, 是 XMLHttpRequest

所以这才导致没有进入任何一个分支,自然xmlhttp未定义
------解决方案--------------------
IE下的有几个不同版本 找齐咯
------解决方案--------------------
别用原生的xmlhttp,用类库吧,jquery,mootools皆可
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template