javascript - Issue With JSON Data -


i'm having weird issue json data.

{     "title" : "counties",     "data": [         {             "name": "baker",             "latlng": [                 "44.65488,-118.42475",                 "44.64548,-118.38275",                 "44.62488,-118.34425",                 "0,0",                 "1,0"             ]         }     ] } 

when use .getjson file data getting syntax error if take out last 2 entries latlng array work correctly.

i put json though linter @ jsonlint.com , says it's valid json chrome , firefox can't parse reason.

the code getting json file:

$(function() {     $.getjson("json/counties.json", function(data){         console.log(data);     });      $(document).ajaxerror(function(event, jqxhr, settings, exception){         console.log(exception);     }); }); 

the exception logged chrome

syntaxerror {}  

and exception logged firefox

[15:07:33.965] (new syntaxerror("json.parse: unexpected non-whitespace character after json data", "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js", 3)) 

as far can tell there aren't characters after json in data, here's screen shot

screen shot

your code working fine me, , data you're showing fine, there must weird going on in environment.

first thing i'd suggest watch raw http response in fiddler or browser's network tab, , see if there's unexpected there - maybe you've got proxy server appending garbage data or that.

if not, try opening counties.json file in binary editor , unexpected byte in there, maybe invisible or funky quotation mark or something. ascii here in example, should pretty easy spot character doesn't belong.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -