I have a theme building website that creates a theme for another project which isn't relevant. I have a few different inputs that have data in them. I am able to get the data and store them in variables. When I click the download button I want the variables to send to a .php file and then download that file. I believe I am sending it ok, but downloading the data seems to be the difficult part.
$("#download-theme").click(function() {
$(function() {
$.ajax({
type: "POST",
url: 'download.php',
data: ({
value: value
}),
success: function(data) {
alert(data);
}
});
});
});
I believe that this sends it to the download.php file as I get the alert with the correct value. What I want to do next is to download the data of the php file as a .txt file. Maybe i'm over complicating it by sending it to the php file i'm not sure.
All in all, I want to get the data from the variable put it in a file, and have the user download it.
EDIT: I saw quentino response and it works, but I have 5 inputs that I would need to be transferred by one submit button.
<input type="text" name="variable1" />
<input type="text" name="variable2" />
<input type="text" name="variable3" />
<input type="text" name="variable4" />
<input type="text" name="variable5" />
<input type="submit" value="send"/>