实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<html><!DOCTYPE html>
2
<html>
3
<head>
4
<script>
5
function loadXMLDoc()
6
{
7
var xmlhttp;
8
if (window.XMLHttpRequest)
9
  {// code for IE7+, Firefox, Chrome, Opera, Safari
10
  xmlhttp=new XMLHttpRequest();
11
  }
12
else
13
  {// code for IE6, IE5
14
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
15
  }
16
xmlhttp.open("GET","/static/example/ajax_info.txt",false);
17
xmlhttp.send();
18
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
19
}
20
</script>
21
</head>
22
<body>
23
24
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
25
<button type="button" onclick="loadXMLDoc()">Change Content</button>
26
27
</body>
28
</html>
29