案例:ajax案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
function loadXMLDoc()
5
{
6
var xmlhttp;
7
if (window.XMLHttpRequest)
8
  {// code for IE7+, Firefox, Chrome, Opera, Safari
9
  xmlhttp=new XMLHttpRequest();
10
  }
11
else
12
  {// code for IE6, IE5
13
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
14
  }
15
xmlhttp.onreadystatechange=function()
16
  {
17
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
18
    {
19
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
20
    }
21
  }
22
xmlhttp.open("GET","/example/ajax/demo_get.aspx",true);
23
xmlhttp.send();
24
}
25
</script>
26
</head>
27
<body>
28
29
<h2>AJAX</h2>
30
<button type="button" onclick="loadXMLDoc()">请求数据</button>
31
<div id="myDiv"></div>
32
33
</body>
34
</html>