Cannot save contents from textarea and force browser to download

Please help, i wrote some code to save contents in the textarea as file, i pass textarea value to server side PHP code using Ajax. Here my Ajax code:

function saveFile()
    {
    document.getElementById("save").childNodes[0].nodeValue="Saving";
                var values = {
                    "txTitle": document.getElementById("title").value,
                    "tex": document.getElementById("textar").value
                };
                $.ajax({
                    url: "SaveFile.php",
                    type: "POST",
                    data: values,
                    cache: false,
                    success: function(data){
      document.getElementById("save").childNodes[0].nodeValue="Save";
                    }
                });
                return false;
    }

And here the code in SaveFile.php file:
https://txeditor.com/jie90r5j0nn

At what point, and in what way, does it go wrong? That is, does it get the correct values from the HTML input boxes correctly, does it pass them correctly to the PHP, what happens?

All values passed correctly to the PHP file, but the browser cannot forced to download the file

All (well, both) of the examples I’ve seen of using Content-disposition: attachment surround the filename with quotes, but you don’t. Does that make any difference?

No, that nothing happened

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.