js中如何使用ajax的get來(lái)向后臺(tái)獲取文件流進(jìn)行文件另存為的下載其中header需要傳token和os參數(shù)到后臺(tái)進(jìn)行驗(yàn)證請(qǐng)問(wèn)這個(gè)JS應(yīng)該如何寫(xiě)?希望大神不吝賜教,謝謝~如下方法后臺(tái)無(wú)法獲取header參數(shù),360瀏覽器中也沒(méi)有啟動(dòng)另存為的窗口var url = "{#$apiHost#}/aw/export?brand_ids="+brand_ids;var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = "blob";
xhr.setRequestHeader("token", "5f963175cc75613398e25ce2e5da56d7");
xhr.setRequestHeader("os", "1");
xhr.onload = function() {
if (this.status == 200) {
try{
var elemIF = document.createElement("iframe");
elemIF.src = this.responseURL;
elemIF.style.display = "none";
document.body.appendChild(elemIF);
}catch(e){
}
}
}
xhr.send();
js中如何使用ajax的get來(lái)向后臺(tái)獲取文件流進(jìn)行文件下載(其中header中傳token參數(shù))
FFIVE
2018-07-19 14:19:56