Buona sera,
ho il seguente codice:
pdf_con_ajax.phpcodice:<html> <head> <script> function assegnaXMLHttpRequest_(){ // lista delle variabili locali var // variabile di ritorno, nulla di default XHR = null, // informazioni sul nome del browser browserUtente = navigator.userAgent.toUpperCase(); // browser standard con supporto nativo // non importa il tipo di browser if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object") XHR = new XMLHttpRequest(); // browser Internet Explorer // è necessario filtrare la versione 4 else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) { // la versione 6 di IE ha un nome differente // per il tipo di oggetto ActiveX if(browserUtente.indexOf("MSIE 5") < 0) XHR = new ActiveXObject("Msxml2.XMLHTTP"); // le versioni 5 e 5.5 invece sfruttano lo stesso nome else XHR = new ActiveXObject("Microsoft.XMLHTTP"); } return XHR; } function genera_pdf(){ var data=""; reqq = assegnaXMLHttpRequest_();//funzione che assegna l'oggetto presa da html.it reqq.open('POST', "pdf_con_ajax.php", true); reqq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;'); reqq.send(data); reqq.onreadystatechange = function(){ if (reqq.readyState == 4){ if (reqq.status == 200){ }else{ alert(reqq.status+" "+reqq.responseText); } } }; } </script> <body> <? echo "<a href=\"#\" onclick=\"genera_pdf();\">GENERA PDF</a>"; ?> </body> </html>
se uso:codice:<? require('mc_table _pers_fatt.php'); $pdf=new PDF_MC_Table(); $pdf->AddPage(); $pdf->SetFont('Arial','',15); $pdf->Cell(0,0,"CIAO",0,1,'L'); $nome_file="prova".date('i_s').".pdf"; $pdf->Output($nome_file,'F'); ?>
$pdf->Output($nome_file,'F');
mi salva il file e va bene;
io però vorrei usare :
$pdf->Output($nome_file,'D');
che mi propone se aprire o salvare. Da ajax non funziona, oppure ho bisogno di qualcosa da dire alla funzione javascript che non so.
Sapete aiutarmi?
Grazie.

Rispondi quotando