Posts Tagged ‘jQuery’

jQuery 1.4.2 upgrade issue when doing json ajax calls

The format requirement for ‘json’ dataType has changed slightly in the new jQuery 1.4.2: Double quotation marks are now a must (for both keys and values) to make ajax calls when specifying dataType: ‘json’ as the return data format. For example, the following json objects are no longer considered to be valid in jQuery 1.4.2:


Attempting to use the above not-strictly-valid json data will result in success option (function) in the ajax() to give up quietly. [ My test result, which is different to what the $.ajax page ( states:

In jQuery 1.4 the JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. (See for more information on proper JSON formatting.)


It’s worth noting that 1.4.2 does not place a strict requirement on the json data being sent to the server, that is,
data: { userid: ‘Joe’, email: ‘’ }
can still be used without causing problems.

[ edit: actually I was not correct about the last paragraph above – the “json data” being sent to the server is javascript object whose key should not be quoted. ]

Categories: Uncategorized Tags: ,