0
<script type="text/javascript">
$(document).ready(function(){
$('#btn_busca_f').click(function () {
var data_ini = $('#data_ini').val();
var data_fim = $('#data_fim').val();
var cod_recurso = $('#cod_recurso').val();
var cod_funcionario = $('#cod_funcionario').val();
var num_op = $('#num_op').val();
$.ajax({
type: 'post',
async: false,
url: '/intranet/ExportaFimApontamento',
data:{
'_token': '{{csrf_token()}}',
'data_ini': data_ini,
'data_fim': data_fim,
'cod_recurso': cod_recurso,
'cod_funcionario': cod_funcionario,
'num_op': num_op
},
erro: function () {
alert('erro');
},
success: function (data) {
return (data);
alert('Excel Gerado com Sucesso!');
}
});
});
});
</script>
this script performs a function in the controller where it generates an excel.xls file, but if I run the function directly in the controler (without going through the page) it works, if I run with the script(up there) it works but does not generate the.xls file, it generates the preview and replay by F12 browser but does not download excel. Does anyone know how to get him to download the file when running the script? or if there is another way? in my form Submit does the function however it is there to consult a report.