I have a problem downloading a file with Internet Explorer
in any version. My problem is that I receive an array of bits from my controller which I receive in JSON
and I download it from javascript
.
Note: I do not have a physical file on the server, this file is obtained from a storage
through a WebService
.
The code works well in other browsers but not in Internet Explorer
$.ajax({
type: 'POST',
url: '/Portal/GetXML',
data: $('#formDownload2' + id).serialize(),
success: function (data) {
if (data.error == "") {
//aquí empieza la descarga del archivo
var arr = data.Archivo;
var byteArray = new Uint8Array(arr);
var a = window.document.createElement('a');
a.href = window.URL.createObjectURL(new Blob([byteArray], { type: 'application/octet-stream' }));
a.download = data.Nombre;
// Append anchor to body.
document.body.appendChild(a)
a.click();
// Remove anchor from body
document.body.removeChild(a)
} else {
$.jGrowl("" + data.error, {
header: "Error",
//sticky: true,
theme: "red"
});
}
}
});
The only thing it does is download a file with a long name and no extension. On other computers with Internet Explorer
download a file with extension: .JSON
Why should I download them in that way? and How can I solve it?