Bug Tracker

Changes between Version 1 and Version 2 of Ticket #8084, comment 3


Ignore:
Timestamp:
Jan 29, 2011, 7:11:48 AM (8 years ago)
Author:
jitter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #8084, comment 3

    v1 v2  
    11After some quick googling this [http://www.bennadel.com/blog/99-JSON-Minor-But-VERY-Important-Detail-Creating-Syntax-Error-Invalid-Label.htm blog post by Ben Nadel] came up. Where he describes an issues related to evaluating json, in short doing `eval( json )` and forgetting the parentheses, instead of `eval( "(" + json ")" )`.
    22
    3 From this I made the following [http://jsfiddle.net/jitter/vghfT/ test case] which triggers this exception.
     3From this I made the following [http://jsfiddle.net/jitter/vghfT/ test case] ~~which triggers this exception.~~ (not anymore as jsfiddle now returns the correct content type). You can this [http://jsfiddle.net/jitter/vghfT/3/ test case] which uses a little trick to simulate the behavior for a missing dataType statement and the server returning the wrong content type.
    44
    55How can this be fixed? Either by setting `dataType: "json"` or by fixing the server to return the correct `Content-Type` for json responses, which would be `application/json` instead of `application/javascript`.