• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

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
0
GlobaLevel
Asked:
GlobaLevel
  • 2
  • 2
1 Solution
 
hieloCommented:
>>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.
0
 
haloexpertsexchangeCommented:
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.
0
 
GlobaLevelAuthor Commented:
R there any examples of code?
0
 
haloexpertsexchangeCommented:
This is written to a php page but you should be able to send it to any serverside page that you want
 $('input:button#edit').click(function(){

    var title = $('#title').val();
    $.get('choose.php',{'title':title}, function(data){
        $('body').append(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.
0
 
hieloCommented:
The sample code you are after would depend on what server-side programming language you have.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now