实例一(Ajax请求基本创建格式):
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ajax练习(GET,不考虑浏览器兼容性)</title>
<script type="text/javascript">
function doRequest() {
//不考虑浏览器兼容性问题
var xmlHttp = new XMLHttpRequest();
//打开一个与Http服务器的连接
xmlHttp.open("GET", "Default.aspx", true);
//与服务器端交互
xmlHttp.send(null);
//监听服务器端响应状态的改变事件
xmlHttp.onreadystatechange = function () {
//客户端与服务器端交互完成
if (xmlHttp.readyState == 4) {
//服务器端返回Http状态码:200表示请求成功,404未找到,403错误
if (xmlHttp.status == 200) {
//获得服务器端资源
var result = xmlHttp.responseText;
alert(result);
}
}
}
}
</script>
</head>
<body>
<form id="form1" runat=&#