1 回答

TA貢獻1770條經(jīng)驗 獲得超3個贊
正如你所說,你不能同時返回兩個響應,我將通過一個文本區(qū)域來解決它,其中包含顯示失敗訂單的 CSV 數(shù)據(jù),并可以選擇將文本下載到文件中
您可以使用此 Javascript 函數(shù)從 TextArea 下載文件
function generateTextFile(textareaElement, filenameWithoutExtension) {
var textToWrite = textareaElement.val();
var textFileAsBlob = new Blob([textToWrite], {type:'text/csv'});
var fileNameToSaveAs = filenameWithoutExtension + ".csv";
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
if (window.webkitURL != null) {
// Chrome allows the link to be clicked
// without actually adding it to the DOM.
downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
}
else {
// Firefox requires the link to be added to the DOM
// before it can be clicked.
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
}
downloadLink.click();
}
添加回答
舉報