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

AJAX 简单调用 - Web 开发 / 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=gb2312" />
<title>简单的异步数据测试</title>
<script type="text/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;
document.write("到这里了");
xmlHttp.open("GET","simple.html",true);
xmlHttp.send(null);
}
function handleStateChange()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
alert("哈哈哈"+xmlHttp.responseText);
}
else
{
alert('错误的测试');
}
}
else
{
alert('错误的测试');
}
}
</script>
</head>

<body>
<form action="#">
<input type="button" value="偶也 测试" onclick="startRequest();"/>
</form>
</body>
</html>


小弟刚刚接触AJAX 是不是哪里写错了 为什么总提示 我 测试错误.请多多指教 3Q

------解决方案--------------------
问题出在页面simple.html,确认你能访问到该页面。页面应在服务器下,即iis下。