我有以下代码......
但显示错误* 未捕获的类型引用无法调用未定义的方法'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
答案 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);
}
})
});