I have content that JS creates in a function and i need to print that content into my downloads folder but when i try to via ajax it will not work and is not throwing any errors
JS code
$.ajax({
url: 'includes/download.php',
type: 'post',
data: {'filename': name_file, 'content': content},
success: function(data, status) {
if(data == "ok") {
console.log('data okay');
}
},
error: function(xhr, desc, err) {
console.log(xhr);
console.log("Details: " + desc + "
Error:" + err);
}
});
PHP code
<?
$filename = $_POST['filename'];
$content = $_POST['content'];
header("Content-type: csd/");
header("Content-Disposition: attachment; filename=".$filename);
print $content;