1

我有以下代码...

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

    <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
4

1 回答 1

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);
            }
        })
    });
于 2013-09-07T08:13:30.500 回答