I am using Laravel Excel to Generate and download files. This is my code on the back end:
$userExports = new UsersExport($filters);
return $userExports->download();
I can download the file using postman but I am facing issues with jquery because I cannot make the browser start the download to the user.
This is my jquery code:
url = Settings.AppSettings.Api + "users/export" + queryString;
var settings = {
"async": true,
"url": url,
"method": "GET",
"headers": {
"Authorization": "Bearer " + Session.AuthKey ,
"cache-control": "no-cache",
},
"processData": false,
}
$.ajax(settings).done(function (response) {
// I don't know what to code here.
}).fail(function (response) {
$(".Preloader").fadeOut();
Materialize.toast(response.responseJSON.message, 3000);
if (response.responseJSON.code == 401) {
Session.Logout();
}
});
This is part of the response or file I am getting
PK �yOG�D�X�[Content_Types].xml��MN�0���"�%nY ��vAa �(0����ؖg�w{&i�@�nbE�{��y��d۸l m�����X�(���)���F��;@1_�����c)j�x/%��E��y� �QĿi!��K�y3�J<���Z1�0?Y�L%zV c��Ib7�����a/l٥P1:�q�r��j��j0A����u�""���(� ���W�M��)Tj�({ܲ�>�O��,X٭���>B��~���Ӥ6�J=�oBZ����t��X4���Cg�,���QgmrL�ٯc�e��t�� Z�?����hPv��±��u�j���R������}�Cv��PK �yO�78�K_rels/.rels���j�0��{ �{���1F�^ʠ�2��l�$���-}