这段ajax错在哪里?????????????????????????????????????
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
window.onload=function(){
var obutton=document.getElementsByTagName("button")[0];
obutton.onclick=function(){
var odiv=document.getElementById("responsetext");
var XHR,ss;
ss=(function(){
return "nihao";
})();
if(window.XMLHttpRequest){
XHR=new XMLHttpRequest();
}
else{
XHR=new ActiveXObject("Microsoft.XMLHTTP");
}
XHR.onreadystatechange=function(){
if(XHR.readyState==4&&XHR.status==200){
odiv.innerHTML=XHR.responseText;
}
else alert("error!");
}
XHR.open("GET","ajax1.asp?act="+ss,true);
XHR.send();
}
}
</script>
<body>
<button>click</button>
<div id="responsetext"></div>
</body>
</html>
------解决方案--------------------
晕,这么简单~
if(XHR.readyState==4&&XHR.status==200)这句
去掉XHR.status==200就行了