Open PDF in new tab (Javascript) when fetching data through curl
I have a question. I have a URL for Phantomjs that generates a PDF. But I want to create a PDF on the server.
<script> $("#generatePDF").click(function(){
var fullLink = "<? echo $link ?>"
$.ajax({
type: "POST",
url: "/php/ajax/generatepdf.php?",
data: {link : fullLink}
}).done( function(data){
window.open(data);
} );
}); </script>
Here I am sending data to generatepdf.php file
Link creates PDF with Phantom.JS
Now I am doing the following in the generatepdf.php file
$link = $_POST['link'];
CurlConnect = curl_init();
curl_setopt($CurlConnect, CURLOPT_URL, $link);
curl_setopt($CurlConnect, CURLOPT_POST, 1);
curl_setopt($CurlConnect, CURLOPT_RETURNTRANSFER, 0 );
$Result = curl_exec($CurlConnect);
echo $Result;
My question is, how can I open a PDF in a new tab with stuff from the Phantom.js result?
Hope you can understand my question.
Regards.
+3
source to share
2 answers