implications of: (xhr.status == 0) => "success" and $.parseJSON("") => null)
Hi.
I've encountered one issue after upgrading to 1.4.2. My app uses GET requests with data type json and I started receiving 'null' when server is down. After a bit of investigation I found a reason for that.
In 1.4.0 empty json response generated "parserror" status, but in 1.4.2 it gives "success" with null data. It was done in commit 781fe8b8 which is fix for
http://dev.jquery.com/ticket/5859.
json.org is not very clear about (in)validness of empty string, but window.JSON parser gives exception in this case. So its probably not very correct to parse empy string as null in exposed to applications json parser.
The problem is that when server is down xhr.status is 0, which is interpreted as "success" (btw, why?). And my json GET's return null instead of failing.
Mozilla 'bug' mentioned in #5859 affects only non-200 and cross-domain responses. So easy fix would be allowing empty string only for responses with status >= 300, but maybe it's better to treat zero status as error ?
Another possible fix (and better, IMO) is reverting 781fe8b8. If some browsers provide response data in this case and some do not, then this needs to be handled by applications anyway. And returning null is no better than giving parserror IMO.