Grr, just spent like 30-45 minutes trying to figure out why the most basic of Ajax loading scripts wouldn't work, something like
$.ajax({
type: "GET",
url: "contexts.json",
dataType: "json",
contentType:"application/json;",
success: function(res){ alert(res);
} );
On the network tab of chrome I could see the request getting made, but nothing was coming up.
Long story shorter, the request was told to parse JSON, but my contexts.json file had map keys that weren't quoted strings. And the parse failure was happening in that weird asynchronous lala land. (Unquoted keys are more or less fine in javascript, because of the way it handles them as labels.)
One way I could have avoided this annoyance was to run all static JSON through my favorite parser at http://json.parser.online.fr/ - it would have told me straightaway that by unquoted keys would blow up.
No comments:
Post a Comment