這是文本文件,我需要讀來讀取文本文件中的文本: http://openweathermap.org/help/city_list.txt
如何使用JavaScript
我在我的桌面上本地保存它,並寫了下面的代碼:
<!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無法加載文件:/// C:/Users/LIRON/Desktop/city_list.txt。 收到無效回覆。因此不允許原產地'null'訪問。
我在做什麼錯?
試過,現在它寫道:沒有「訪問控制允許來源」標頭呈現在請求的資源上。因此不允許原產地'null'訪問。 – user3587197