I am trying to pass a value of a button using some ajax to a separate file.
Here is my code.
$("input#downloadSingle").click(function() {
var myData = $("input#downloadSingle").val();
$.ajax({
type: 'post',
url:'singleDownload.php',
data: myData,
success: function(results) {
alert('works');
}
});
});
However, when I test out the next page by doing a var_dump on $_POST. I don’t get any data back. Thoughts?
You’re not specifying the name of the
$_POSTvariable you’re gonna get on thesingleDownload.phpfile (unless that’s part of the button’s value), so you should try something like:And make sure
$_POSTin your php file is the samewhatevervariable