Angel Moral Posted April 23, 2019 Share Posted April 23, 2019 I have a file named nadie.tpl whose driver is NadieController.php, I want it to use a controller function through AJAX. The problem is in the introduction of the url in the AJAX query that does not work for me, it was tested so that nobody, nobody.php, NadieController, NadieController.ph, etc. nadie.tp (Location: themes / classics / templates) {extends file='page.tpl'} {block name='page_title'} <span class="sitemap-title">{l s='Plantilla descargable' d='Shop.Theme'}</span> {/block} {block name='page_content_container'} <section> <p><label>Introduce ancho:</label> <input type="text" id="name" name="name" maxlength="8" size="10" /></p> <p><label>Introduce alto:</label> <input type="text" id="name" name="name" maxlength="8" size="10" /></p> <button onclick="myFunction()">Click me</button> <p id="demo"></p> </section> {literal} <script> function myFunction() { document.getElementById("demo"); console.log("Entro myfuncion"); $.ajax( { type: 'POST', data: {action:'getPDF'}, url: i dont know how to call NadieController.php, success: function (response) { console.log(response); } } ); } </script> {/literal} {/block} NadieController.php (Ubicación: controllers/fronts) <?php class NadieControllerCore extends FrontController { public $php_self = 'nadie'; public function initContent() { parent::initContent(); if(isset($_POST['action']) && !empty($_POST['action'])) { echo "<script>console.log( 'Entro IF' );</script>"; $action = $_POST['action']; switch($action) { case 'getPDF' : getPDF();break; // ...etc... } } $this->setTemplate('nadie'); } public static function getPDF(){ ob_start(); require('vendor/fpdf/fpdf.php'); $pdf = new FPDF('P','mm',array(20,10)); $pdf->AddPage(); $pdf->Output(); } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now