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 ?
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 ?
Share Improve this question asked Oct 12, 2012 at 11:47 Abhendra SinghAbhendra Singh 1,9574 gold badges28 silver badges46 bronze badges 5- Check this post. stackoverflow./questions/1296085/download-file-using-jquery – Eric Leroy Commented Oct 12, 2012 at 11:51
- It works only when i have a file already created. But i don't have such type of any file. – Abhendra Singh Commented Oct 12, 2012 at 11:54
- Why can't you use a server side language or ajax? – Eric Leroy Commented Oct 12, 2012 at 11:56
- This is a sample demo service. We are not using java and any other server side programming. This is normal HTML project. – Abhendra Singh Commented Oct 12, 2012 at 12:09
-
Is there anyway to change the download file name? Right now it just shows as
download
?! – Omar Wagih Commented Nov 20, 2013 at 1:05
2 Answers
Reset to default 8<a href="data:application/octet-stream;charset=utf-8;base64,U29tZSBjb250ZW50">Download "Some content" as a text file</a>
http://jsfiddle/5tJ5p/
You're looking for Downloadify.