MENU
Retrieving a Static File
When the button is clicked, the content of the file "test.txt" in the server is displayed.
RESETRUNFULL
RESETRUNFULL
<!DOCTYPE html><html><head>
<script>
function loadText(){
var xhr;
xhr=new XMLHttpRequest();
xhr.onreadystatechange=function(){
if (xhr.readyState==4 && xhr.status==200)
document.getElementById("div").innerHTML=xhr.responseText;
};
xhr.open("GET","test.txt",true);
xhr.send();
}
</script></head>
<body>
<div id="div"></div>
<button type="button" onclick="loadText()">
Retrieve Text</button>
</body></html>