案例: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.open("GET","/jsjq/ajax/test1.txt",false);
16
xmlhttp.send();
17
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
18
}
19
</script>
20
</head>
21
<body>
22
23
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
24
<button type="button" onclick="loadXMLDoc()">通过 AJAX 改变内容</button>
25
26
</body>
27
</html>