I run into issue what ie7 doesn't support blob data type.
And now i can't force browser(ie7) to load file which i pass from server with get request.
Modern browsers(chrome, firefox) do it well with this js code
var xhr = new XMLHttpRequest();
xhr.open('GET', COEFF_CONTROL_GET_CSV_FILE_URL + "&" + "DWL_PERIOD=2019&DWL_MR=37", true);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
//Code below implements file load
var contentDisposition = xhr.getResponseHeader('content-disposition');
var filename = contentDisposition.split("filename=")[1].split(";")[0];
var blob = new Blob([xhr.response], {type: 'text/csv'});
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = filename;
document.body.appendChild(link);
link.click();
}
}
Headers that i pass with my request from server for now
header("Content-Type", "text/csv;charset=utf-8");
header("Content-Disposition", "attachment;filename=&mvFileName");
I tried already(but it did't help)
Will be appreciate for all possible help!
You are using the IE 7 browser which is too old and out of support scope of Microsoft.
As Blob is not supported in IE 7, your code will not be going to work for IE 7 version.
I suggest you use the latest Microsoft browsers. If you are not able to use the latest Microsoft browsers then at least move to IE 11 version. Blob is supported from IE 10 version.
For the IE 11 browser, I suggest you make a test with Navigator.msSaveBlob() method.
The Navigator.msSaveBlob() method saves the File or Blob to disk. This method behaves in the same way as Navigator.msSaveOrOpenBlob() except that this disables the file open option.
Example:
var blob = new Blob(["Sample String\r\n,For Checking, msSaveBlob"],{
type:'text/csv;charset=utf-8;'
});
if(navigator.msSaveBlob){
navigator.msSaveBlob(blob,"sample.csv");
}
References: