(Closed) Javascript: outputting a .txt file as a string -




so have function takes contents of .txt file , returns string... or @ least should. instead, returns "undefined". however, "console.log(text);" outputs proper text, makes me believe can't convert contents string since has line breaks in it, different text on each line of .txt file. how can convert output string can use .split , convert array (having each line of text in notecard translate separate item in 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> 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -