I wrote a simple generator for creating sentences. It works well, but I am having a printing problem. When I try to print a page from an AJAX request, I get the index page, not the data from the AJAX request.
What's wrong?
Also, the data from AJAX is correct.
$.post({
type: "POST",
url: "generate.php",
data: {pid: pid, net: net, brutto: brutto, contractor: contractor, delivery: delivery, term: term},
}).done(function(data) {
window.print(data);
});
Example for a PHP file:
<?php
$foo = "foo";
ob_start();
?>
<p><?php echo $foo; ?></p>
<?php
$result = ob_get_flush();
echo $result;
?>
source
share