3

I have a java script file in which a variable has some string like:

var xw = 'Some content';

I want to download this string as a file. How to do this in JQuery/javascript? I don't want to send any request on server using AJAX. Is there any way to download in purely JQuery/javascript ?

Abhendra Singh
  • 1,959
  • 4
  • 26
  • 46

2 Answers2

8
<a href="data:application/octet-stream;charset=utf-8;base64,U29tZSBjb250ZW50">Download "Some content" as a text file</a>

http://jsfiddle.net/5tJ5p/

skovalyov
  • 2,069
  • 1
  • 16
  • 12
2

You're looking for Downloadify.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964