[請益] 新手http response無法顯示求解
<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也建立了裡面也有內容
希望各位大大給新手一點幫助
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.135.159.117
※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1484881760.A.70B.html
→
01/20 11:27, , 1F
01/20 11:27, 1F
→
01/20 11:37, , 2F
01/20 11:37, 2F
推
01/20 13:46, , 3F
01/20 13:46, 3F
感謝大家幫忙,不過更改過後還是無法顯示我在poetry.txt中的文字
請問還有哪裡出問題呢?
更改過後的程式碼如下
https://goo.gl/B9unxk
※ 編輯: biggood20708 (220.135.159.117), 01/20/2017 18:13:22
推
01/20 19:34, , 4F
01/20 19:34, 4F
→
01/20 19:34, , 5F
01/20 19:34, 5F
→
01/20 19:40, , 6F
01/20 19:40, 6F
推
01/21 01:07, , 7F
01/21 01:07, 7F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章