I am learning about AJAX
and am trying to get the contents of my file "info.txt" to be displayed inside a div
with id
"demo". However it keeps returning blank. Unfortunately, in order to test this you would have to try this code on an actual server (which I am) and have to supply your own "info.txt" file. I please supply a standard javascript answer (non-JQuery), please!
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "info.txt", true);
xhttp.send();
document.getElementById("demo").innerHTML = xhttp.responseText;
}
<div id="demo">
<h1>The XMLHttpRequest Object</h1>
<button type="button" onclick="loadDoc()">Change Content</button>
</div>