大量尝试读取将代表jpg图像的二进制数据流httprequest的响应之后,仍然挣扎着。javascript中的httprequest和二进制数据
编辑:整个事情
xmlhttp = false;
/*@[email protected]*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@[email protected]*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp = false;
}
}
xmlhttp.open("GET", theUrl, true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
var headers = xmlhttp.getAllResponseHeaders();
}
}
xmlhttp.send(null);
我使用IE8,并没有HTML 5(也试过在FF12) 所以我总是用一些错误落得像
xhr.overrideMimeType('text\/plain; charset=x-user-defined');
或
xhr.responseType = "arraybuffer";
即使复制到一个变量不会工作
var body = xhr.response; //.responseText , .responseBody
任何想法最新错误或wwhat我可以尝试?
为什么?你想达到什么目的?你的服务器可以做b64编码吗? – mplungjan
没有它的嵌入式设备和公司不会悲伤地改变他们的界面 – Gobliins
但是,你应该如何在脚本端使用二进制数据? – Raffaele