I'm trying to make a webpage that will display the contents of a text file, this file will eventually be stored online when the webpage is hosted, however, right now I am testing the webpage locally with the file being stored in the same directory as the html file. Below is the code I am using but I'm running into the error " Messages is not defined"
<script type="text/javascript">
function loadFile(filePath) {
var result = null;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", filePath, false);
xmlhttp.send();
if (xmlhttp.status==200) {
result = xmlhttp.responseText;
}
return result;
}
document.getElementById("test").textContent = loadFile(Messages.txt);
</script>