My JSON webservice uses HTTP Status codes.

I know it's a novel idea to use internationally agreed upon standards (and hardly anyone does it...) but come on Firefox! WTF!? I thought standards are what you were all about!?

I send a bad password via xhr and my webservice responds 422 Unprocessable Entity with JSON which describes the error in greater detail.

Firefox turns that response into an empty string!!! But if the status code is 2xx it works fine. Huh? What? Huh?

jQuery 1.4 is set up to parse using window.JSON and As it turns out an empty string isn't proper JSON and an exception is thrown. WebApp go BOOM!

I'd like to submit a bug to Mozilla, but I have to wait for their mail system to get through to mine... and hence I decided to blog about it.

In the meantime... I guess I lie and use 200 status codes? I don't know. That seems to be the simplest solution.

By AJ ONeal

If you loved this and want more like it, sign up!

Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )