I'm trying to learn some html/css/javascript, so I'm writing myself a teaching project.(我正在尝试学习一些html / css / javascript,因此我正在为自己编写一个教学项目。)
The idea was to have some vocabulary contained in a json file which would then be loaded into a table.(想法是在json文件中包含一些词汇,然后将其加载到表中。)
I managed to load the file in and print out one of its values, after which I began writing the code to load the values into the table.(我设法加载文件并打印出其中一个值,然后开始编写代码以将值加载到表中。)
After doing that I started getting an error, so I removed all the code I had written, leaving me with only one line (the same line that had worked before) ... only the error is still there.(完成此操作后,我开始出现错误,因此删除了我编写的所有代码,只剩下一行(以前工作过的同一行)……只有错误仍然存??在。)
The error is as follows:(错误如下:)
Uncaught SyntaxError: Unexpected token o
(anonymous function)script.js:10
jQuery.Callbacks.firejquery-1.7.js:1064
jQuery.Callbacks.self.fireWithjquery-1.7.js:1182
donejquery-1.7.js:7454
jQuery.ajaxTransport.send.callback
My javascript code is contained in a separate file and is simply this:(我的JavaScript代码包含在一个单独的文件中,就是这样:)
function loadPageIntoDiv(){
document.getElementById("wokabWeeks").style.display = "block";
}
function loadWokab(){
//also tried getJSON which threw the same error
jQuery.get('wokab.json', function(data) {
var glacier = JSON.parse(data);
});
}
And my JSON file just has the following right now:(我的JSON文件现在具有以下内容:)
[
{
"english": "bag",
"kana": "kaban",
"kanji": "K"
},
{
"english": "glasses",
"kana": "megane",
"kanji": "M"
}
]
Now the error is reported in line 11 which is the var glacier = JSON.parse(data);
(现在,该错误在第11行中报告,即var glacier = JSON.parse(data);
)
line.(线。)
When I remove the json file I get the error: "GET http://.../wokab.json 404 (Not Found)" so I know it's loading it (or at least trying to).(当我删除json文件时,出现错误:“ GET http://.../wokab.json 404(未找到)”,因此我知道它正在加载(或至少尝试加载)。)
ask by Bjorninn translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…