【发布时间】:2014-04-29 22:48:57
【问题描述】:
这是我需要读取的文本文件:
http://openweathermap.org/help/city_list.txt
我把它本地保存在我的桌面并写了以下代码:
<!html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" ></script>
<script>
$(document).ready(function () {
$.get('city_list.txt', function(data) {
var lines = data.split(/\n/);
});
});
</script>
</head>
<body>
hello
</body>
</html>
我得到的错误是:
XMLHttpRequest 无法加载 file:///C:/Users/LIRON/Desktop/city_list.txt。 收到无效回复。因此,不允许访问 Origin 'null'。
我做错了什么?
【问题讨论】:
标签: javascript file text