JavaScript - return data to user via button click

Curious if code already exists out there that allow a user on button click on HTML page to run a process that wil take the data from a querystring and in loop form write it to a txt file in columns that they can save to their pc...
Columns look like:
Response/subject/phone number/message
LVL 10
Who is Participating?
This is written to a php page but you should be able to send it to any serverside page that you want

    var title = $('#title').val();
    $.get('choose.php',{'title':title}, function(data){

Open in new window

This takes a value from a form but you can pass any information that you want.
It does an ajax call to the server side page, where it does what ever it needs and what gets returned is  anything that is printed out from the server side page.
So you then append the data to wherever you want on the page, with this one I just appended it to the body itself.
What I would suggest is that you get the jquery to fire on an onclick event which will then grab what ever information you need and do an ajax call to a serverside page which will do all database calls and then writes file for you. What you will return back will be a link to that file which the user can then save where ever they want.
I might be able to be somewhat more specific if I knew what kind of server side languages you were comfortable working with so that I could find appropriate examples in that language.
>>take the data from a querystring and in loop form write it to a txt file
If the browser would allow you to do that, then many people (just for the fun of it) would write an infinite loop just so the user's harddrive would run out of space. Again - just for fun :)

To answer your question directly, the browser is not allowed to write files directly.
you can write a jquery/ajax call which can be triggered on an on click event and send off a call to a page in your favorite server side code which can then write the text file for you.
GlobaLevelProgrammerAuthor Commented:
R there any examples of code?
The sample code you are after would depend on what server-side programming language you have.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.