ajax prestashop 1.5 front controller -
how made ajax call in new page called controller in prestashop. example:
-i have form page call formulario.php in root folder -this page call formulariocontroller.php in controller folder , shows me perfect tpl , page, tpal in themes/default folder
but here issue when make ajax call checking form , load errors or result in div put page again inside div not response.php call.
any ideas how fix , or guide make ajax call page. doc of prestashop ajax not clear
thank
did find page? http://doc.prestashop.com/display/ps15/using+jquery+and+ajax#usingjqueryandajax-makingajaxcallswithjquery
i used develop module. take lot other module use ajax call (can't remember ones does).
here's how can ajax call :
var query = $.ajax({ type: 'post', url: basedir + 'modules/mymodule/ajax.php', data: 'method=mymethod&id_data=' + $('#id_data').val(), datatype: 'json', success: function(json) { // .... } });
and then, need create php file. using way, prestashop core won't loaded, have manually if want use prestashop function :
// http headers no cache etc header("expires: mon, 26 jul 1997 05:00:00 gmt"); header("last-modified: " . gmdate("d, d m y h:i:s") . " gmt"); header("cache-control: no-store, no-cache, must-revalidate"); header("cache-control: post-check=0, pre-check=0", false); header("pragma: no-cache"); require_once(dirname(__file__).'/../../config/config.inc.php'); require_once(dirname(__file__).'/../../init.php');
to generate json output, can use :
die(tools::jsonencode($myarrays));
hope got need.
Comments
Post a Comment