Module Prestashop AJAX调用模块
因此,我无法让这个prestashop模块快速查看我试图添加的每个产品的点击 我将模块放在/modules/quicklook下的基本目录中 档案如下 /modules/quicklook.phpModule Prestashop AJAX调用模块,module,prestashop,Module,Prestashop,因此,我无法让这个prestashop模块快速查看我试图添加的每个产品的点击 我将模块放在/modules/quicklook下的基本目录中 档案如下 /modules/quicklook.php class QuickLook extends Module { private $_html= ''; function __construct() { $this->name = 'quicklook'; $this->tab = 'other'; $thi
class QuickLook extends Module {
private $_html= '';
function __construct() {
$this->name = 'quicklook';
$this->tab = 'other';
$this->version = '0.2.0';
$this->author = 'Carl';
parent::__construct();
$this->displayName = $this->l('Quick Look');
$this->description = $this->l('AJAX Quick Look');
}
public function install() {
parent::install();
if(!$this->registerHook('header')) return false;
return true;
}
public function getContent()
{
$this->_displayForm();
return $this->_html;
}
public function ajaxCall() {
$this->smartyOutputContent($this->getTemplatePath() . 'quicklook.tpl');
}
}
/模块/quicklook.tpl
包括product.tpl中的所有内容
/模块/quicklook-ajax.tpl包括:
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/quicklook.php');
$quicklook = new QuickLook();
echo $quicklook->ajaxCall();
然后,为了调用模块,我在product-list.tpl中添加了以下内容:
<script type="text/javascript">
function QuickLook() {
$.ajax({
url: '{$base_dir}modules/quicklook/quicklook-ajax.php',
type: 'get',
data: 'ajax=true',
success: function(data) {
console.log('success');
$('#ajax').text(data);
}
});
return false;
}
</script>
我要走了
Failed to load resource: the server responded with a status of 404 (Not Found)
对于未定义的。。而且产品没有加载
因此,基本上我试图让每个产品的a href链接执行javascript,该javascript调用ajax桥文件,然后调用quicklook.php,然后调用quicklook.tpl,显示产品,希望我的思路是正确的(这是我第一次尝试模块!)
我真的很想在正确的方向上得到一些指导。在这一点上,我不确定出了什么问题(1)首先检查是否存在quicklook-ajax.php文件
2) 检查通过url获得访问权限的可能性:{$base_dir}modules/quicklook/quicklook-ajax.php,否则也会出现404错误
3) 最好的方法是为此创建自己的控制器(如何做到:),并使用Link::getModuleLink()获取url
问候嘿,亚历山大,非常感谢你的回复。404错误实际上已经消失了,因为我认为它与我正在使用的灯箱有关,但现在我已经切换到已经并入Prestashop的Fancybox。因此,现在我在控制台中获得“成功”,但在lightbox中获得“加载资源失败”。我使用的是“$”(“单个图像”).fancybox()然后在链接上使用“{$product.name | escape:'htmlall:'UTF-8'| truncate:26:'…':true}”。我通过Javascript调用AJAX可能有问题?
Failed to load resource: the server responded with a status of 404 (Not Found)