案例:XML 实例     状态:不可编辑再运行    进入竖版
 运行结果 
x
With a HEAD request, a server will return the headers of a resource (not the resource itself). This means you can find out the Content-Type or Last-Modified of a document, without downloading it itself.
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
var xmlhttp
5
6
function loadXMLDoc(url)
7
{
8
xmlhttp=null
9
// code for Mozilla, etc.
10
if (window.XMLHttpRequest)
11
  {
12
  xmlhttp=new XMLHttpRequest()
13
  }
14
// code for IE
15
else if (window.ActiveXObject)
16
  {
17
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
18
  }
19
if (xmlhttp!=null)
20
  {
21
  xmlhttp.onreadystatechange=state_Change
22
  xmlhttp.open("GET",url,true)
23
  xmlhttp.send(null)
24
  }
25
else
26
  {
27
  alert("Your browser does not support XMLHTTP.")
28
  }
29
}
30
31
function state_Change()
32
{
33
// if xmlhttp shows "loaded"
34
if (xmlhttp.readyState==4)
35
  {
36
  // if "OK"
37
  if (xmlhttp.status==200)
38
  {
39
  document.getElementById('T1').innerHTML="This file was last modified on: " + xmlhttp.getResponseHeader('Last-Modified')
40
  }
41
  else
42
  {
43
  alert("Problem retrieving data:" + xmlhttp.statusText)
44
  }
45
  }
46
}
47
48
</script>