課程
/前端開(kāi)發(fā)
/JavaScript
/Ajax全接觸
為什么我的返回值顯示在頁(yè)面上是undefined?求幫助。
2016-10-29
源自:Ajax全接觸 3-4
正在回答
是不是request.reponse.Text這里輸入錯(cuò)誤了,你輸入的.Test
吶禰 提問(wèn)者
qq_小火車_04020340 回復(fù) 吶禰 提問(wèn)者
吶禰 提問(wèn)者 回復(fù) qq_小火車_04020340
<script>
document.getElementById("monday").onclick = function(){
//發(fā)送Ajax請(qǐng)求,并處理。
var request = new XMLHttpRequest();
request.open("GET","detail.php?id=1");
request.send();
request.onreadystatechange = function(){
if (request.readyState === 4) {
if (request.status === 200) {
document.getElementById("echo").innerHTML = request.responseTest;
alert(request.responseTest);
}else{
alert("發(fā)生錯(cuò)誤:" + request.status);
}
</script>
代碼如上。請(qǐng)求是成功的,可在審查元素的response里看到正確的返回值,但是顯示到頁(yè)面上就變成了undefined。不知道是什么問(wèn)題。
有辦法截圖么,這樣大家都不知道具體情況
舉報(bào)
本課程通過(guò)一個(gè)案例,講解Ajax的相關(guān)概念原理實(shí)現(xiàn)方式和應(yīng)用
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-10-29
是不是request.reponse.Text這里輸入錯(cuò)誤了,你輸入的.Test
2016-10-29
<script>
document.getElementById("monday").onclick = function(){
//發(fā)送Ajax請(qǐng)求,并處理。
var request = new XMLHttpRequest();
request.open("GET","detail.php?id=1");
request.send();
request.onreadystatechange = function(){
if (request.readyState === 4) {
if (request.status === 200) {
document.getElementById("echo").innerHTML = request.responseTest;
alert(request.responseTest);
}else{
alert("發(fā)生錯(cuò)誤:" + request.status);
}
}
}
}
</script>
代碼如上。請(qǐng)求是成功的,可在審查元素的response里看到正確的返回值,但是顯示到頁(yè)面上就變成了undefined。不知道是什么問(wèn)題。
2016-10-29
有辦法截圖么,這樣大家都不知道具體情況