I have a form which submit a form via AJAX with :remote => true. Looking at the server log and FireBug, I get the response 200 OK and it returns JSON in the form of:
JSON.parse('') throws an error. To me, that is stupid, it should return undefined. I added this code to my app
#HACK JSON.parse('') should return undefined, not throw an error
_parse = JSON.parse
JSON.parse = (str) =>
unless str == ''
_parse.apply JSON, arguments
or for u poor people not using coffeescript ( untested )
//HACK JSON.parse('') should return undefined, not throw an error
var _parse = JSON.parse
JSON.parse = function(str) {
if (str !== '')
return _parse.apply(JSON, arguments);
else
return undefined;
}