I have the following JavaScript code:
alert(data.status);
data is a JSON object, one of its fields is status (a Boolean field).
When JSON.stringify(data) returns:
{"result":[{"income":"1000","expense":"2000"}],"errors":{},"status":true}
the code above does output true, but when JSON.stringify(data) returns:
{"result":null,"errors":{"user":"nonexistent user"},"status":false}
the code above breaks – i.e. it does not alert anything, and the rest of my JavaScript code is not executed as well.
Any idea why, and/or how to fix/bypass it?
Your error is elsewhere. Try this simple test in Firebug (or some other console):
It works fine.