Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download file from jquery/javascript

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 ?

like image 572
Abhendra Singh Avatar asked Aug 02 '26 21:08

Abhendra Singh


2 Answers

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

http://jsfiddle.net/5tJ5p/

like image 78
skovalyov Avatar answered Aug 04 '26 12:08

skovalyov


You're looking for Downloadify.

like image 25
SLaks Avatar answered Aug 04 '26 10:08

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!