How to print the response using AJAX/Javascript?
本问题已经有最佳答案,请猛点这里访问。
我正在学习
1 2 3 4 5 6 | function loadDoc() { var xhttp = new XMLHttpRequest(); xhttp.open("GET","info.txt", true); xhttp.send(); document.getElementById("demo").innerHTML = xhttp.responseText; } |
1 2 | The XMLHttpRequest Object <button type="button" onclick="loadDoc()">Change Content</button> |
您传递给
您需要删除
1 2 3 4 5 6 7 8 9 10 | function loadDoc() { var xhttp = new XMLHttpRequest(); xhttp.open("GET","info.txt", true); xhttp.onreadystatechange = function () { if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) { document.getElementById("demo").innerHTML = xhttp.responseText; } }; xhttp.send(); } |