您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
获取文件流
var url = "/map/download?_beanid="+_beanid+"&buttonid="+buttonid; var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = "blob"; xhr.onload = function() { if (this.status == 200) { //var blob = this.response; var blob = new Blob([this.response]); /*if(d.headers('content-disposition').indexOf('filename') != -1){ downloadTitle = d.headers('content-disposition').split(';')[1].split('=')[1]; downloadTitle = decodeURI(downloadTitle); }待用*/ if(typeof window.navigator.msSaveBlob !== 'undefined'){ window.navigator.msSaveBlob(blob, downloadTitle); }else{ var objectUrl = URL.createObjectURL(blob); var aForExcel = $("<a download='"+downloadTitle+"'><span class='forExcel'>下载excel</span></a>").attr("href",objectUrl); $("body").append(aForExcel); $(".forExcel").click(); aForExcel.remove(); } var _h = $(window).height(); var $div=$("<div />"); $div.dialog({ "modal": true, "resizable": false, "showmax":false, "maxHeight": false, "maxWidth": false, "minHeight": 600, "minWidth": 50, "width":"100%", "height":_h, "draggable":false, "title":filename, "open":function(){ var $ifr = "<iframe frameborder='0' width='100%' filename='"+filename+"' height='100%' id='fileImportIO' src='../struts/data/spread_ui.ftl'></iframe>"; $div.append($ifr); $("#fileImportIO").data("fileIO",blob); }, "close":function(event, ui){ parent.$("#fileImportIO").attr("src","about:blank"); $(event.target).closest("#wapper").empty().remove(); } }); } } xhr.send();
2.发送文件流
var xhr = new XMLHttpRequest(); xhr.open("POST", '/map/download!save', true); xhr.onload = function (oEvent) { if(this.status == 200){ if(this.response == "success"){ alert(this.response); } } }; xhr.send(blob);
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。