JavaScript

$.getJSON Not Working

If the format of the JSON file is not strictly JSON, it would not work.

Common errors include:

1. No double quotes around property name:

{City: "Mayberry"}      // wrong
{"City": "Mayberry"}    // right

2. Single quotes around anything:

{'City': 'Mayberry'}    // wrong
{"City": "Mayberry"}    // right

3. Anything other than property/value pair as Array element:

{"Cities": ["Mayberry", "Gotham"]}    // wrong
{"Cities": [{"Name": "Mayberry"}, {"Name": "Gotham"}]}    // right
Standard