However, we do not have to update the page. This code works perfectly in google chrome, but in mozilla firefox and Microsoft Edge simply does not do anything, the download does not start or show any error in the console. Am I doing something wrong or is it an incompatibility problem?
Ajax:
$.ajax({
url:"../../views/ajax.php",
method:"POST",
data:dato,
cache:false,
contentType: false,
processData:false,
xhrFields: {
responseType: 'blob'
},
beforeSend: function() {
$("#loading").removeClass('d-none');
},
success: function(regresos){
alert(regresos);
$("#loading").addClass('d-none');
descargar(regresos, nombre);
}
});
The function that starts the download:
function descargar(blob, nombre){
var a = document.createElement('a');
var url = window.URL.createObjectURL(
new Blob([ blob ], { type: 'application/octet-stream' })
);
a.href = url;
a.download = 'perfil_' + nombre + '.pdf';
a.click();
window.URL.revokeObjectURL(url);
}