0

My main problem is dsnt working downloads on Safari. For now i'm using FileSaver.js. It's working on all browsers but on safari, file is opened in new tab instead of downloading it. File is creating by user, its JSON data.

var dataAsText = JSON.stringify(data); //Convert JSON to text
var blob = new Blob([dataAsText], {type: "text/plain"});
saveAs(blob, $("#menu-save-text").val()+".leds");

How to use AJAX and PHP to make safari downloading file instead of opening it?

sko
  • 431
  • 1
  • 5
  • 10
  • what happens if you change `var blob = new Blob([dataAsText], {type: "text/plain"});` to `var blob = new Blob([dataAsText], {type: "application/json"});` – Jonathan Crowe Oct 27 '14 at 22:23
  • Same. Other way if change to `application/octet-stream` doing nothing, cant even open in new tab. – sko Oct 27 '14 at 22:25
  • http://stackoverflow.com/questions/9723262/download-a-file-by-changing-window-location-w-safari seems related – Jonathan Crowe Oct 27 '14 at 22:28
  • It doesn't work. Safari dsnt support download attribute, Filesystem API too. – sko Oct 27 '14 at 22:42

0 Answers0