Sunday, October 30, 2005

Explorer system error: -1072896658

Don't you love when explorer express its griefs in such a clear and helpful way?

I was putting the last touches to the new "Search place" code, and it was working beautifully in Firefox and in Explorer, when I faced a problem in Safari. The query to the database that retrieves the name of places that match the user search came back with the accents garbled!

Safari thought the received page, that I was retrieving with XMLHttpRequest behind the scenes, was encoded in ISO-8859-1 (or most probably, -15) when I was serving it in UTF-8.

Fair enough, I just have to put the header "Content-Type: text/plain; charset=utf8" in the reply, and sure enough, Safari was now working like a charm.

But then, the search stopped working at all in Internet Explorer! I was getting a weird error in the status bar:

Explorer system error: -1072896658

This thing popped when I tried to access the responseText of the request object. After I googled a bit this error code, I found that it was due to the XMLHttpRequest control receiving a reply on an unknown encoding. Please guys, next time put a message like:

XMLHttpRequest requested document was in the unknown "utf8" encoding. See the list of accepted encodings.

It turns out the charset should be UTF-8, and not utf8. Fixed it, and now it is happily working on these 3 browsers.

Update: Attentive reader Johan Sundström pointed out that I was missing the "text/plain; charset=" part on the Content-Type. I should really double check my blog entries before posting them.