So I have this function that takes the contents of a .txt file and returns it as a string... or at least it should. Instead, what it returns is "undefined". However, the "console.log(text);" outputs the proper text, which makes me believe that I can't convert the contents to a string since it has line breaks in it, with different text on each line of the .txt file. How can I convert the output to a string so that I can use .split and convert it to an array (having each line of text in the notecard translate into a separate item in the array)? Please help!
<script>//_____Read_Text_File_____
function done()
{
var fileContents = this.response;
var text = fileContents;
console.log(text);
return text;
}
function readTxt(fileName) {
var xmlhttp;
xmlhttp=new XMLHttpRequest();
xmlhttp.addEventListener("load", done, false);
xmlhttp.open("GET",fileName,true);
xmlhttp.send();
}
</script>