【发布时间】:2019-10-12 01:57:08
【问题描述】:
我想将 ajax 数据发送到控制器页面并在 prestashop 1.6 的模板文件上显示 ajax 数据。
我正在使用这种方法但无法得到任何结果 -
tpl 文件:
<input type="button" class="btn btn-primary" id="test" onclick = "testing()" value="test" />
function testing() {
url = '{$link->getModuleLink("hotelapi", "filter")|escape:"html"}';
$.ajax({
url: url,
type : 'GET',
cache : false,
data : {
ajax: 1,
action: 'fetchTPL',
},
success: function(html){
alert("SUCCESS:");
},
error: function() {
alert("ERROR:");
}
});
}
前端控制器文件-文件名是-filter.php
<?php
/*require (dirname(__FILE__) . '/../../../../config/config.inc.php');
require (dirname(__FILE__) . '/../../../../init.php');*/
class hotelapiFilterModuleFrontController extends ModuleFrontController
{
public function displayAjaxFetchTPL()
{
echo 'hello';
//after processing all data just assign it to smarty of content
/*$this->context->smarty->assign(array(
'youContentData' => $_POST['room'])
);
// to fetch a tpl file use fetch method and use die function to return the response to ajax
die($this->context->smarty->fetch('a1.tpl'));*/
}
}
我的 ajax url 执行成功,但我无法打印在 displayAjaxFetchTPL 操作中写入的任何内容。
请任何人帮助我解决这个问题。
感谢和问候, Ridhi Bhutani
【问题讨论】:
标签: php ajax prestashop prestashop-1.6