I just came across this fantastic article, which has a number of things to contribute. Firstly, how to get that crock-of-browser IE to work.
Secondly, it has some lovely advice for partners on how to deal with us web developers when we’re not going to bed until this works.
Here it is: A Fun Little JSON Murder Mystery With IE9
I thought I’d also point out, partly for reminding me next time I am ripping hair out and depositing it in the gaps between the keys, and partly for the edification of others, that this is far from the only gotcha IE likes to throw up.
Every now and then your find yourself involved with the X-JSON header. This is usually if you’re still using a very old version of Rails, or have for some other reason decided to use a similarly old version of prototype.js. (I assume that if you’re doing this, you’re also battling a scriptaculous addiction - move on, there’s newer shinier stuff). Old version of prototype (1.5 ish) use a custom header to read JSON responses instead of response body, which means you are limited in certain browsers to a 168 characters. This is covered here. One ugly way to deal with this is to have your server pretend it’s sending Content-Type: text/plain, and manually decode the JSON. Or you could upgrade prototype to 1.7, or jQuery.
IE will also usually believe the Content-Length header you give with a JSON response, so make sure you get it right.
Some XMLHttpResquests, and some servers will also get very upset if you send and empty POST request. Always give it some content. Otherwise you probably mean GET, DELETE, HEAD or something like that. If you’re posting something, remember to put it in the envelope, and add the stamp.
Something else to be aware of on the other side of the transaction is dealing with things like Spring’s jackson backed message adapter. Always remember to set the Content-Type of the POST.
Well, I hope some of that will save me and hopefully some others a few late night ‘dur’ moments.