从文本文件创建导航

时间:2013-09-07 08:09:15

标签: javascript

我有以下代码......

但显示错误* 未捕获的类型引用无法调用未定义的方法'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

1 个答案:

答案 0 :(得分:0)

删除.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);
            }
        })
    });
相关问题