<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>创建第一个AJAX程序</title>
<script type="text/javascript">
var xmlHttp;
//创建XMLHttpRequest对象
function CreateXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpReuqest();
}
}
function StartXMLHttpRequest()
{
CreateXMLHttpRequest();
xmlHttp.open("GET","http://blog.csdn.net/wkjs",true);
xmlHttp.send(null);
xmlHttp.onreadystatechange=onloadreadyState;
}
function onloadreadyState()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.Status==200)
{
document.getElementById("result").innerHTML=xmlHttp.responseText;
}
}
}
</script>
</head>
<body>
<form action="#">
<input id="show" type="button" onclick="StartXMLHttpRequest()" value="获取信息" />
</form>
<div id="result">
</div>
</body>
</html>
<head>
<title>创建第一个AJAX程序</title>
<script type="text/javascript">
var xmlHttp;
//创建XMLHttpRequest对象
function CreateXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpReuqest();
}
}
function StartXMLHttpRequest()
{
CreateXMLHttpRequest();
xmlHttp.open("GET","http://blog.csdn.net/wkjs",true);
xmlHttp.send(null);
xmlHttp.onreadystatechange=onloadreadyState;
}
function onloadreadyState()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.Status==200)
{
document.getElementById("result").innerHTML=xmlHttp.responseText;
}
}
}
</script>
</head>
<body>
<form action="#">
<input id="show" type="button" onclick="StartXMLHttpRequest()" value="获取信息" />
</form>
<div id="result">
</div>
</body>
</html>