案例:XML案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
var xmlhttp;
5
function loadXMLDoc(url)
6
{
7
xmlhttp=null;
8
if (window.XMLHttpRequest)
9
  {// code for IE7, Firefox, Opera, etc.
10
  xmlhttp=new XMLHttpRequest();
11
  }
12
else if (window.ActiveXObject)
13
  {// code for IE6, IE5
14
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
15
  }
16
if (xmlhttp!=null)
17
  {
18
  xmlhttp.open("GET",url,false);
19
  xmlhttp.send(null);
20
  document.getElementById('A1').innerHTML=xmlhttp.status;
21
  document.getElementById('A2').innerHTML=xmlhttp.statusText;
22
  document.getElementById('A3').innerHTML=xmlhttp.responseText;
23
  }
24
else
25
  {
26
  alert("Your browser does not support XMLHTTP.");
27
  }
28
}
29
</script>
30
</head>
31
32
<body>
33
<h2>Using the HttpRequest Object</h2>
34
35
<p><b>Status:</b>
36
<span id="A1"></span>
37
</p>
38
39
<p><b>Status text:</b>
40
<span id="A2"></span>
41
</p>
42
43
<p><b>Response:</b>
44
<br /><span id="A3"></span>
45
</p>
46
47
<button onclick="loadXMLDoc('/example/xdom/note.xml')">Get XML</button>
48