<html>
<head>
<script type="text/javascript">
var xmlhttp;
function loadxmldoc(url)
{
xmlhttp=null;
if (window.xmlhttprequest)
{// code for firefox, mozilla, ie7, etc.
xmlhttp=new xmlhttprequest();
}
else if (window.activexobject)
{// code for ie6, ie5
xmlhttp=new activexobject("microsoft.xmlhttp");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_change;
xmlhttp.open("get",url,true);
xmlhttp.send(null);
}
else
{
alert("your browser does not support xmlhttp.");
}
}
function state_change()
{
if (xmlhttp.readystate==4)
{// 4 = "loaded"
if (xmlhttp.status==200)
{// 200 = "ok"
document.getelementbyid('p1').innerhtml=xmlhttp.getallresponseheaders();
}
else
{
alert("problem retrieving data:" + xmlhttp.statustext);
}
}
}
</script>
</head>
<body>
<p id="p1">
the getallresponseheaders() function returns the headers of a resource.
the headers contain file information like length,
server-type, content-type, date-modified, etc.</p>
<button onclick="loadxmldoc('/example/ajax/test_xmlhttp.txt')">get headers</button>
</body>
</html>
新闻热点
疑难解答
图片精选