如何使用PrestaShop中使用jQuery Ajax调用PHP静态方法



在tpl smarty文件中,我通常会调用PHP方法如下

{assign var='all_categories' value=SpecificPrice::getByProductId($product.id_product)}
                            {foreach from=$all_categories item=all}
								<pre>{$all_categories|@print_r}</pre>
								<div class="offername" style="background: red;width: 58%;color: white;font-size: 12pt;padding-top: 6px;"> {$all.offer_name} </div>
                            {/foreach}

,但我想在ajax

中调用相同的方法

SpecificPrice::getByProductId($product.id_product)

如何在Ajax中调用此方法?

您在Prestashop中的AJAX无法调用任何功能,但是您可以调用您在控制器中创建的自定义函数。

您可以使用以下过程来做到这一点:

  • 首先,为模块创建一个前控制器。

  • 将请求发送到其URL,并在Postprocess((函数中处理

更多详细信息在这里:http://doc.prestashop.com/display/ps16/using jquery and ajax

最新更新