Modify the export button to additionally trigger an Ajax request.
Modify the export button to additionally trigger an Ajax request.
![FiezDev](https://secure.gravatar.com/avatar/99605f58c682980bfb1df40528a9d6a0/?default=https%3A%2F%2Fvanillicon.com%2F99605f58c682980bfb1df40528a9d6a0_200.png&rating=g&size=120)
I created a customized Excel export button with code similar to this.
{
extend: 'excel',
text: '<i class="fas fa-file-excel text-primary_orange"></i> Excel',
titleAttr: 'Export to Excel',
title: 'Export to Excel',
exportOptions: {
columns: ':not(.noExport)',
},
action: function (e ,dt ) {
let obj = dt.buttons.exportData()
let data = {
'data': obj,
'currentUrl': window.location.href,
};
$.ajax({
type: "POST",
url: "/logexport/?type=excel",
data: JSON.stringify(data),
});
}
},
Although the AJAX request is sent as expected, the file-saving popup doesn't work. How can I fix this issue?
Answers
Please see Allan's comment on this thread - as I think that'll do the trick for you too,
Colin