我想获取.txt文件的每一行并将其作为javascript列表的元素

时间:2019-05-14 12:58:07

标签: javascript arrays

/*I want to fill my javascript list with elements from txt file. Each line as element.

I can fill my list manually. But not with elements from txt file. 

此函数返回1和2(每个30秒后)。我想返回.txt文件的内容(逐行)。 * /

<script>
var text = ["1","2"];          
var counter = 0;
var elem = document.getElementById("changeText");
var inst = setInterval(change2, 30000);

            function change2() {
                    elem.innerHTML = text[counter];
                    counter++;
                    if (counter >= text.length) {
                        counter = 0;
                                  }
                                }
 </script>

0 个答案:

没有答案