将arraybuffer转换为字符串:超出最大调用堆栈大小 [英] Converting arraybuffer to string : Maximum call stack size exceeded
本文介绍了将arraybuffer转换为字符串:超出最大调用堆栈大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码行.
var xhr = new XMLHttpRequest();
xhr.open('GET',window.location.href, true);
xhr.responseType = "arraybuffer";
xhr.onload = function(event) {
debugger;
console.log(" coverting array buffer to string ");
alert(String.fromCharCode.apply(null, new Uint8Array(this.response)));
};
xhr.send();
该请求是针对pdf网址的,该网址的大小约为3 MB.读取具有相同错误的几个线程,告诉您必须有一些递归调用,但是我在这里看不到任何递归调用.有帮助吗?
That request is making to a pdf url which is around 3 MB in size. Read few thread with same error, telling that there must be some recursive call but I do not see any recursive call here. Any help ?
推荐答案
该错误是由于函数参数数量的限制而引起的.参见"RangeError:超出最大调用堆栈大小"为什么?
The error is caused by a limitation in the number of function arguments. See "RangeError: Maximum call stack size exceeded" Why?
使用e代替String.fromCharCode.apply()
. G. TextEncoder
.请参见 Uint8Array以JavaScript字符串化
Instead of String.fromCharCode.apply()
, use e. g. a TextEncoder
. See Uint8Array to string in Javascript
这篇关于将arraybuffer转换为字符串:超出最大调用堆栈大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文