ローカルテキストファイルを読み込んで、音節や文字のカウントなどの機能を実行しようとしています。
私はこれを行うことによってこれを行おうとしています:
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "file://path/to/my/file.txt", true);
txtFile.onreadystatechange = function() {
if (txtFile.readyState === 4) { // Makes sure the document is ready to parse.
if (txtFile.status === 200) { // Makes sure it's found the file.
allText = txtFile.responseText;
//lines = txtFile.responseText.split("\r\n"); // Will separate each line into an array
} //"\r\n"
}
}
'txtFile'をコマンドラインに記録しようとすると、[ObjectHtmlRequest]が出力されますが、ロードしているものを確認して、それを反復処理するにはどうすればよいですか?
このコードを実行しようとすると、エラーメッセージも表示されます
var text = txtFile
//$(this).val();
//document.text_input.my_text.value = newtext;
var words = new Array(text.replace(/\s/g, ' ').split(' '));
以前は機能していましたが、テキストを使用しなくなったため、現在は機能していないと思います