1

I am not a programmer, so please forgive me if my question is too silly. I have created a very simple website which takes the first name, last name and then a very simple javascript file says Thank You <first name> <last name> and done. I figured HTML through YouTube videos and found this javascript

    function signFunction(firstName, lastName){
    alert("Thank you , " + firstName + " " + lastName + "!");       
}

I just want to know how can I save the output of javascript to a text file. I am using Apache in Debian.

  • Javascript can't write to files directly. It needs to use a form submission or AJAX to send the data to a script that runs on the server, and the server script can save to a file. – Barmar Apr 07 '17 at 01:51
  • @Barmar This is untrue. Files can be saved using the `saveAs` DOM function, as well as generating dynamic `data:` URIs with an "attachment" content-disposition. There is also the `Blob` API as well. – Dai Apr 07 '17 at 01:51
  • Possible duplicate of [Javascript: Create and save file](http://stackoverflow.com/questions/13405129/javascript-create-and-save-file) – Dai Apr 07 '17 at 01:52
  • Are you trying to save to a file on the server or the client machine? – Barmar Apr 07 '17 at 01:53
  • @Barmar to a text file on my Debian server – THE COMPTGUY Apr 07 '17 at 01:58
  • @Dai Your duplicate is for saving on the client, he wants to save on the server. – Barmar Apr 07 '17 at 01:59
  • @THECOMPTGUY In that case my first comment is correct, you need a server-side script to save the file. – Barmar Apr 07 '17 at 02:00
  • @Barmar, so there is no simple script to save? – THE COMPTGUY Apr 07 '17 at 02:04
  • No, there's nothing that does this automatically. Clients aren't supposed to be able to write directly to a server, it's supposed to be mediated by the application running on the server. – Barmar Apr 07 '17 at 02:07

0 Answers0