此代码应帮助您从远程文本文件中读取:
var txtFile = new XMLHttpRequest();txtFile.open("GET", "http://my.remote.url/myremotefile.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("n"); // Will separate each line into an array } }}txtFile.send(null);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)