gpt4 book ai didi

javascript - 从文本文件创建导航

转载 作者:行者123 更新时间:2023-11-28 08:54:34 25 4
gpt4 key购买 nike

我有以下代码...

但显示错误 *未捕获类型引用无法调用未定义的方法“split”*

    <script src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var textFile = "nav.txt";
jQuery.get(textFile, function (textFileData) {
var EachLineInTextFile = textFileData.responseText.split("\n");
for (var i = 0, len = EachLineInTextFile.length; i < len; i++) {
STORE_TO_REPLACE = EachLineInTextFile[i];
//STORE_TO_REPLACE: I would have to the entire format of your file to do this.
console.log(STORE_TO_REPLACE);
}
})
});
</script>

nav.txt 文件如下

a a.aspx
b b.aspx
c c.aspx

最佳答案

删除.responseText部分。

    $(document).ready(function () {
var textFile = "nav.txt";
jQuery.get(textFile, function (textFileData) {
var EachLineInTextFile = textFileData.split("\n");
for (var i = 0, len = EachLineInTextFile.length; i < len; i++) {
STORE_TO_REPLACE = EachLineInTextFile[i];
//STORE_TO_REPLACE: I would have to the entire format of your file to do this.
console.log(STORE_TO_REPLACE);
}
})
});

关于javascript - 从文本文件创建导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18671238/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com