Jump to content

custom page


Recommended Posts

Ciao a tutti

volevo stampare via ajax in una custom_page.tpl una stringa proveniente da una public function del controller.

 

qualcuno sa dirmi come procedere?

 

controllers/front/CustomPageController.php

 

public function initContent(){
   parent::initContent();
   
  if($this->ajax) //special variable to check if the call is ajax
   {
     $this->f(); 
   }
   
$this->setTemplate(_PS_THEME_DIR_.'custom-page.tpl');
}
 
 public function f() {
        return 'messaggio prova';
       }
 
 
 
 
custom_page.tpl
  $.ajax({
       type: "POST",
       controller: 'controllers/front/CustomPageController',
       contentType: "application/json",
       dataType: "json",
       data: JSON.stringify({
          
       }),
       success: function(response) {
           alert(response+"succ");
       },
       error: function(response) {
           alert(response+"err");
       }
});
 
 
 
 
Grazie dell'aiuto!

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...