代码
var xhr0 = new XMLHttpRequest();
xhr0.open("get", 'page/file.bin', true);
xhr0.onreadystatechange = function() {
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
console.log("data:")
console.log(xhr0.response)
}
}
xhr0.send();页面的响应头之一
Content-Type: application/x-download;charset=ISO-8859-1虽然我不能确定文件的确切编码,因为它是加密的。我需要以与文件相同的方式查看文件。二进制(十六进制视图)。
发布于 2019-07-24 02:51:23
通过使用response type
就像这样
var xhr0 = new XMLHttpRequest();
xhr0.open("get", 'page.bin', true);
xhr0.responseType = "blob";
xhr0.onreadystatechange = function() {
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
console.log("data:")
var blob1 = xhr0.response
console.log(blob1)
}
}
xhr0.send();它看起来像这样的image
https://stackoverflow.com/questions/57136083
复制相似问题