Can you please support me?
I am developing a simple system for a company, they want to generate service orders. It is a form with various inputs that the client fills in order to generate a PDF with all this information.
Using htmltopdf link The code is simple:
<-- formulario con inputs id="generarOrden"-->
// jquery
/* Pruebas de formulario de orden de servicio */
$("#generarOrden").off("submit").on("submit", function(e){
e.preventDefault();
var data = $(this).serialize();
$.ajax({
url : "procesos/ordenes.php" ,
dataType : "json" ,
type : "post" ,
data : data ,
success : function(rD){
/* Resultado correcto */
if (rD.status == 200) {
console.log("Petición correcta");
}
/* Error en la petición */
if (rD.status == 404) {
console.log("Algo está mal");
}
}
})
});
//archivo procesos/ordenes.php (solo de pruebas)
if (isset($_POST)) {
// Guardar los valores en variables de SESSION para su uso
foreach ($_POST as $key => $value) {
$_SESSION["ordenDeServicio"][$key] = $value;
}
// Tipo de orden de servicio
$tipo = (isset($_GET["tipo"])) ? "blank" : "filled";
$orden = new PDF();
return json_encode(array("status" => 200 , "response" => $orden->generar_orden_de_servicio($_POST)));
exit();
} else {
http_response_code(400);
return false;
}
Everything up there works correctly, it returns me in the callback the pdf as such:
I want to know if I can open that ajax response in another tab showing the pdf or force a download, but I can not get it.