当前位置:首页 > 前端 > 正文

blob数据ajax传输

下载:

$http.get(‘/receivePDFUrl‘, {responseType: ‘arraybuffer‘}) // 设置$http get请求的responseType为arraybuffer
 .success(function(data){
  var file = new Blob([data], {type: ‘application/pdf‘}); // 使用Blob将PDF Stream 转换为file
  var fileUrl = URL.createOjectURL(file);
  window.open(fileUrl); // 在新的页面中打开PDF
 })

 

上一篇
HTML5,从零开始

下一篇
JS特效