function downloadFile(url, fileName) { var x = new XMLHttpRequest(); x.open("GET", url, true); x.responseType = 'blob'; x.onload = function (e) { var url = window.URL.createObjectURL(x.response) var a = document.createElement('a'); a.href = url a.download = fileName; a.click() } x.send(); }