I am working on creating this website and my Javascript is having issues. I'm getting the error: Uncaught SyntaxError: Unexpected identifier This occurs with one of my lines on my Javascript.
我正在努力创建这个网站,我的Javascript有问题。我收到错误:Uncaught SyntaxError:意外的标识符我的Javascript上有一行代码。
var temp=localStorage.getItem(volunteerOpp);
newObject = JSON.parse(temp);
display newObject[0];
It is showing this error on line 3, I think and I'm unsure what the problem is.
它在第3行显示这个错误,我想,我不确定问题是什么。
2 个解决方案
#1
0
That's the error JSON.parse throws when you don't feed it nice json. Have a close look at volunteerOpp for syntax errors, perhaps a property name not in double quotes.
这是JSON.parse引发的错误,当你不喂它好json。仔细查看volunteerOpp的语法错误,也许是不是双引号的属性名称。
#2
0
I'm not sure what you want, but you can try this:
我不确定你想要什么,但你可以尝试这个:
var temp = localStorage.getItem(volunteerOpp),
newObject = JSON.parse(temp);
console.log(temp);
console.log(newObject);
console.log(newObject[0]);
#1
0
That's the error JSON.parse throws when you don't feed it nice json. Have a close look at volunteerOpp for syntax errors, perhaps a property name not in double quotes.
这是JSON.parse引发的错误,当你不喂它好json。仔细查看volunteerOpp的语法错误,也许是不是双引号的属性名称。
#2
0
I'm not sure what you want, but you can try this:
我不确定你想要什么,但你可以尝试这个:
var temp = localStorage.getItem(volunteerOpp),
newObject = JSON.parse(temp);
console.log(temp);
console.log(newObject);
console.log(newObject[0]);