日期:2014-05-16  浏览次数:20597 次

新手问题~~~~~请各位帮忙 - Web 开发 / Ajax
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title> </title> 
<script language="javascript"> 

var xmlhttp; 

function createXMLHttpRequest() 

if(window.ActiveXObject) 

xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 

else if(window.XMLHttpRequest) 

xmlhttp = new XMLHttpRequest(); 



function startRequest() 

createXMLHttpRequest(); 
xmlhttp.onreadystatechange = handleStateChange; 
xmlhttp.open("GET","simpleRequest.xml",true); 
xmlhttp.send(null); 


function handleStateChange() 

if(xmlhttp.readyState == 4) 

if(xmlhttp.status == 200) 

document.getElementById("results").innerHTML = xmlhttp.responseText; 




</script> 
</head> 

<body> 

<form action="#"> 

<input type="button" value="afasfasfasf" onclick="startRequest();" /> 

</form> 

<div id="results"> </div> 

</body> 
</html> 

simpleRequest.xml文件中的内容是如下: 
<table border="1"> 
<tbody> 
<tr> 
<th>time </th> 
<th>location </th> 
<th>name </th> 
<th>birthday </th> 
</tr> 
<tr> 
<th>12313 </th> 
<th>asfasf </th> 
<th>wolf </th> 
<th>87698789 </th> 
</tr> 
</tbody> 
</table> 

为什么就是调试不出来呢,没有任何显示或者报错~~~~ 我是初学ajax,是需要什么配置还是什么啊??

------解决方案--------------------
ajax不需要配置什么.
------解决方案--------------------
JScript code
function handleStateChange()  
{  
if(xmlhttp.readyState == 4)  
{  
if(xmlhttp.status == 200||xmlhttp.status == 0)//xmlhttp.status==0 加上,如果你是直接拖进浏览器的话
{  
document.getElementById("results").innerHTML = xmlhttp.responseText;  
}  
}  
}

------解决方案--------------------
我也是刚刚接触,需要学习呀.