为什么我能';你不能使用javascript和jquery读取文本文件吗?
代码如下:为什么我能';你不能使用javascript和jquery读取文本文件吗?,javascript,jquery,html,Javascript,Jquery,Html,代码如下: <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src="http://newsxpressmedia.com/files/theme/jquery.newsTicker.js"></script> <script>$(function() { var file = "http://newsxpressmedia
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://newsxpressmedia.com/files/theme/jquery.newsTicker.js"></script>
<script>$(function() {
var file = "http://newsxpressmedia.com/files/theme/test.txt";
$.get(file, function (txt) {
//var lines = txt.responseText.split("\n");
var lines = txt.split("\n");
$ul = $('<ul class="newsticker" />');
for (var i = 0, len = lines.length; i < len; i++) {
//save(lines[i]); // not sure what this does
$ul.append('<li>' + lines[i] + '</li>');
}
//$ul.appendTo('body').newsTicker({
$ul.appendTo('div.wcustomhtml').newsTicker({
row_height: 48,
max_rows: 2,
speed: 6000,
direction: 'up',
duration: 1000,
autostart: 1,
pauseOnHover: 1
});
});
});
autostart: 1,
pauseOnHover: 0
});
</script>
$(函数(){
变量文件=”http://newsxpressmedia.com/files/theme/test.txt";
$.get(文件、函数(txt){
//var lines=txt.responseText.split(“\n”);
变量行=txt.split(“\n”);
$ul=$(');
对于(变量i=0,len=lines.length;i”+行[i]+“”);
}
//$ul.appendTo('body')。新闻票证({
$ul.appendTo('div.wcustomhtml')。新闻代码({
行高:48,
最大行数:2,
速度:6000,
方向:'向上',
持续时间:1000,
自动启动:1,
暂停悬停:1
});
});
});
自动启动:1,
暂停悬停:0
});
链接存在且未给出404未找到。
但是我没有看到文本文件中的行正在读取
我在“审核”选项卡中单击我的站点Ctrl+Shist+C,我看到一个错误:
意外的标记:test.html:120我点击它,有一个空行就是它。
我没有使用,也没有任何名为test.html的文件
目标是jquery每次读取一两行并向上滚动
这是网站:
您的javascript代码格式不正确。从javascript中删除此选项:
autostart: 1,
pauseOnHover: 0
});
您应该从函数末尾删除此过时代码:
});
autostart: 1,
pauseOnHover: 0
见@Marty Word
废话
不允许提及?即使是废话?:)不一定要诚实:S