Retrieving binary data with XMLHttpRequest, again
A few months ago I concluded that it is simply not possible to download binary files for Ajax purposes, at least not with Firefox (see Retrieving binary data with XMLHttpRequest).
It boils down to using the right Charset in with the proprietary overrideMimeType() function. Read his post to see how.
In one word: Wow! This opens up a whole lot of new applications, for instance with Greasemonkey scripts.
I’m glad I have been proven wrong!
Update: this does not work for me as is…
What happens is that all bytes above 127 (decimal) are returned as a really big value. The solution, however, appears to be very simple:
var filestream = load_url(url); var c = filestream.charCodeAt(x); if (c > 255) c -= 63232;
Apparently, the extra high value is not caused by extra bytes being gobbled up, but constructed on the fly. Luckily this is done in such a deterministic way.
I’m really interested in other users’ experiences. Please share them via the feedback form!