Я использую
$.ajax({
url: '/search',
data: $('form').serialize(),
type: 'POST',
async: true,
// process the response from the backend
success: function(response) {
console.log(response);
if (response.search_text !== "") {
$('#search_result_text').html("Your search " + "<font color='red'>" + response.search_text +
"</font>" + " in category " + "<font color='red'>" + response.category + "</font>" +
" has " + "<font color='red'>" + response.amount_hits_search_text + "</font>" + " hits in:")
$('#hits_document').html("all documents: " + "<font color='red'>" +
response.amount_hits_document_total + "</font>" + "<br>" + "mgmt. documents: " +
"<font color='red'>" + response.amount_hits_documents_mgmt + "</font>")
export_csv.style.visibility = "visible";
}
// function to export all hit results
$('#export_csv').click(function() {
console.log("trying to download")
var blob = new Blob([response.csv], {
type: "text/csv;charset=utf-8;"
});
if (navigator.msSaveBlob) { // IE 10+
navigator.msSaveBlob(blob, response.search_text + " " + response.category + ".csv")
} else {
var link = document.createElement("a");
if (link.download !== undefined) { // feature detection
// Browsers that support HTML5 download attribute
var url = URL.createObjectURL(blob);
link.setAttribute("href", url);
link.setAttribute("target", "_blank")
link.setAttribute("download", "fileName.csv");
link.style = "visibility:hidden";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
link.removeChild()
URL.revokeObjectURL(url)
}
}
})
)}
)}
для создания большого двоичного объекта для Inte rnet Explorer.
Кнопка "export_csv" генерирует CSV, который я могу загрузить впоследствии. Но я понял, что капля не «перезаписана». Когда я создал 3 CSV-файла и загружал их при каждом щелчке, четвертый CSV-файл и щелчок приведут также к загрузке всех прежних 3 CSV / файлов BLOB-объектов!
Как удалить каждый BLOB-объект после загрузки?
Заранее спасибо.