[英]Error with ajax cart when add product on prestashop
嘿,自上周以来,我遇到了一个prestashop 1.6.0.11和ajax购物车的问题
当我单击“添加到购物车”按钮时,页面上和标题中的购物车上没有任何操作。 (如果我刷新页面,则产品在购物车中)。
我的控制台中出现此错误:
ajax-cart.js:329 =>未捕获的TypeError:无法读取null的属性“ hasError”
发送了ajax请求,但结果为“ null”:
https://www.prestashop.com/forums/uploads/monthly_10_2015/post-833314-0-21064100-1444814390.png
https://www.prestashop.com/forums/uploads/monthly_10_2015/post-833314-0-07732700-1444814388.png
编辑:
这是ajax-cart.js的js代码:
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseUri + '?rand=' + new Date().getTime(),
async: true,
cache: false,
dataType : "json",
data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): ''),
success: function(jsonData,textStatus,jqXHR)
{
// add appliance to whishlist module
if (whishlist && !jsonData.errors)
WishlistAddProductCart(whishlist[0], idProduct, idCombination, whishlist[1]);
/* line 329 => */ if (!jsonData.hasError) // <-- jsonData object is NULL , why ?
{
// ...
在PHP中,可以正常工作的Prestashop和该版本之间没有区别。
编辑2:
我在CartController.php的displayAjax()中找到了程序停止的位置:
if (Tools::getIsset('summary')) // == false
{
什么是“摘要”?
有人有解决办法吗?
解决了
问题来自Smarty插件,该插件在某些TPL的开头添加了一些字符。
因此,Json Encode返回错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.