javascript (SyntaxError): 使用 eval 时元素列表后缺少 ]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11215185/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
(SyntaxError): missing ] after element list when using eval
提问by MyTitle
I get following error (SyntaxError): missing ] after element list
when using eval
function.
Returned JSON is pretty simple, so I don't undestand where is error.
(SyntaxError): missing ] after element list
使用eval
函数时出现以下错误 。返回的 JSON 非常简单,所以我不明白错误在哪里。
[{"title":"sfsdf","id":1}{"title":"m356","id":12}]
回答by g.d.d.c
As an answer for completeness. Your JSON is invalid. You need a comma between the Objects like so:
作为完整性的答案。您的 JSON 无效。您需要在对象之间使用逗号,如下所示:
[{"title":"sfsdf","id":1},{"title":"m356","id":12}]
回答by HymanLin
First you have lost the comma between the Object,the Second Jquery will parse the Object automaticly. i suggest you don't use this method. i also meet thie question,but there're some difference from yours.
首先你丢失了对象之间的逗号,第二个 Jquery 会自动解析对象。我建议你不要使用这种方法。我也遇到了这个问题,但和你的有些不同。