开发者

JSON.parse Issues

开发者 https://www.devze.com 2023-03-09 03:42 出处:网络
so, I am working on a website for a client, a friend of mine. He sells geckos, and he has made a website for himself, and his sales partner, and I am doing a lot of javascript work for him, IE AJAX, e

so, I am working on a website for a client, a friend of mine. He sells geckos, and he has made a website for himself, and his sales partner, and I am doing a lot of javascript work for him, IE AJAX, etc开发者_如何学JAVA... Well, I got to the available lizard page for him, and I am making a sort of dynamic gecko selection system. The way this script is supposed to work is, fetch a JSON file (here) which is perfectly good JSON, and then parse the values in to multiselects. I'm using the jQuery.get function to do this. All goes well until I try parsing the JSON data, and the browser, firefox, throws the error "Syntax Error: JSON.parse", and chromium throws the error "Unexpected Token", the problem also occurred with

The error is thrown on line 219 of js.js,

jQuery.parseJSON(). 

the issues are in the function drawCat(data), the page this code is in use on is Here

I hope that this is a quality question, I'm really quite tired to be coding right now, it pretty late.


Actually that is not valid JSON. It's easy to check at http://jsonlint.com/. The error is that the root should be either one JSON object or an array. Now you have several JSON objects as roots.

Update: Danjah is also correct. After you fix this the problem he highlights will also cause invalid JSON. so you need to fix both.


I don't think its valid, there's a bunch of missing commas part way down the file, screenshot attached as no line numbering.

JSON.parse Issues

0

精彩评论

暂无评论...
验证码 换一张
取 消