<html>
<head>
<meta http-equiv="content-type" content = "text/html;charset=utf-8">
<script src = "utility.js" type = "text/javascript"></script>
<script type = "text/javascript">
var XHR = null;
function startRequest()
{
XHR = createXMLHttpRequest();
XHR.open("GET","poetry.txt",true);
XHR.onreadystatechange=handleStateChange;
XHR.send(null);
}
function handleStateChange()
{
if(XHR.readyState == 4)
{
if(XHR.status == 200)
document.getElementByid("span1").innerHTML=XHR.responseText;
else
window.alert("error!");
}
}
</script>
</head>
<body>
<form id = "form1">
<input id = "button1" type = "button" value = "显示"
onclick="startRequest()">
<br><br><span id = "span1"></span>
</form>
</body>
</html>
基本上是照参考书上打的,但是button按了就一直显示不出来
看了半天也不知道哪里出错,poetry.txt也建立了里面也有内容
希望各位大大给新手一点帮助