XmlHttpRequests to simple views fail to return in MSIE
|Reported by:||kevin@…||Owned by:||nobody|
|Severity:||Keywords:||MSIE, XMLHttpRequest, views, Json|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I've been using Django for some UI prototyping work to return templates as well as data responses to XMLHttpRequests (XML, XHTML, JSON, etc.) and came across a really unusual bug.
In short, if I write a really simple view like this:
Then call that view via XMLHttpRequest from any version of MSIE, MSIE will report that the request has failed when clearly Django returned the data just fine (reports error code 200, and identical code works fine in Firefox).
However I found -- quite by accident, as it turns out -- that one of my views always worked in MSIE. Through process of elimination I realized the only difference: I was printing the content of request.POST to the console for debugging purposes:
With that one extra line, MSIE accepts the response every time. This doesn't seem like a good fix for production environments -- and maybe it doesn't matter, as I haven't verified that the problem exists there -- but it certainly caused me a lot of frustrating trying to validate my code under MSIE, and wanted to save people some grief in case they have encountered similar problems.