I am trying to retrieve the data of an image in Javascript using XMLHttpRequest
.
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.celticfc.net/images/doc/celticcrest.png");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
var resp = xhr.responseText;
console.log(resp.charCodeAt(0) & 0xff);
}
};
xhr.send();
The first byte of this data should be 0x89
, however any high-value bytes return as 0xfffd
(0xfffd & 0xff
being 0xfd
).
Questions such as this one offer solutions using the overrideMimeType()
function, however this is not supported on the platform I am using (Qt/QML).
How can I download the data correctly?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…