VM603:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1

再用JQuery解析json的时候出现了这样一个问题

VM603:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1

通过查阅资料发现,是由于解析json文件的时候解析到object而引起的错误。通过console.log的输出,发现输出的结果是一个类似于数组的输出内容。

通过寻找发现由于JQuery版本的升级,JQuery的ajax方法发生了变化,ajax的sucess的回调值直接将json解析,造成了这种错误。

 所以在版本的JQuery中,并不需要手动解析Json,直接调用即可。

参考资料:

1.VM603:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1?

2.jQuery AJAX call returns [object Object]

3.JSON.parse()方法之后报错

4.jQuery.parseJSON()

原文地址:https://www.cnblogs.com/shubin/p/7462780.html