<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也建立了裡面也有內容
希望各位大大給新手一點幫助