【发布时间】:2016-07-18 09:04:52
【问题描述】:
这是我的代码。
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();
正在向大小约为 3 MB 的 PDF URL 发出该请求。我已经阅读了一些具有相同错误的线程,超出了最大调用堆栈大小,告诉我必须有一些递归调用,但我在这里看不到任何递归调用。有人可以帮忙吗?
【问题讨论】:
-
这个请求是否指向同一个页面?在
window.location.href上使用GET? -
@skobaljic 可以。比如当前页面是cs.columbia.edu/~lok/3101/lectures/02-corejava.pdf
-
如果您调用包含相同脚本的同一页面,为什么您会怀疑递归过多?尝试在没有脚本的情况下调用其他页面。或者如果您通过 xhr 调用,则不要再次输出脚本,或者添加参数以区分调用。
-
@skobaljic 这个脚本不会在加载函数中执行。我只是在阅读pdf页面数据。
-
您是否尝试加载其他页面,其他 pdf?
标签: javascript jquery encoding data-conversion arraybuffer