functiononClickFunction(){
var request = new XMLHttpRequest();
request.open("GET", "http:URLToGetFile", true);
request.responseType = "arraybuffer";
request.onload = function (e) {
if (this.status === 200) {
var arraybuffer=this.response;
console.log(this.response);
var pdffile = new Blob([arraybuffer],{type: "application/pdf"});
var fileURL = window.URL.createObjectURL(pdffile);
window.open(fileURL);
};
};
request.send();
}
我试图在点击按钮时在新窗口中显示pdf,但显示错误“无法加载PDF文档”。有人能告诉我我做错了吗?