Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"Prior to 1.9, an ajax call that expected a return data type of JSON or JSONP would consider a return value of an empty string to be a success case, but return a null to the success handler or promise. As of 1.9, an empty string returned for JSON data is considered to be malformed JSON (because it is); this will now throw an error."

That one is gonna cause some headaches, I've abused this behavior for years, as recently as yesterday.



So your server returns an HTTP 200 with an empty response, and you process the `null` in your success handler? Do you really want a `null` returned? Is this a server you control, or is it some third-party service? Just curious about the use case and how widespread it might be.


I was probably in control of all of them at some level but I either didn't think about it or didn't care enough. Sometimes I suck. Today I can start sucking a little less.


This confused me for a minute but I think I get it now -- it's referring to a response with zero length, not a response of two quote characters right?


Yes, but two quote characters on their own isn't valid JSON either so that'll error too, though I assume it already did.


This stuff never works happily. I don't really trust jQuery to handle JSON/JSONP properly.

It is easy enough to drop back down to calling XMLHttpRequest by hand. Sample code is here, and changes to jQuery won't break it: http://stackoverflow.com/questions/5395118/jquery-1-5-json-e...


Why did you not just specify the dataType in your ajax call?

http://api.jquery.com/jQuery.ajax/#data-types


Because was working with jQuery 1.5, and data-types showed up in 1.5.1


It sounds like you knew it was bad practice, and yet you did it anyways...?




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: