我有opencart。功能addToCart()将产品添加到购物车在正常页面上正常工作。Opencart addToCart收到空回复
我做了自定义页面,我只有那个触发函数addtoCart()的按钮。只是正常的按钮..
在普通页面(它工作)我得到正常的响应。
请看图片的链接: http://imgur.com/7M1AR1B,FKjiU05,9ggmiMR#2
第三图像实际上是后期的作品好,第二张照片是响应该工程确定。 第一张图片是我在打开的购物车中的自定义页面中获得的空响应。
你知道为什么会发生这种情况吗?
我使用函数addToCart()并在该自定义页面中使用硬变量FOR TEST,这意味着变量始终在那里通过。我使用硬变量,所以我不必解释如何在代码中传递变量(它的工作原理相同,它在调试中传递所有内容)。问题是我只在自定义页面上获得了“空”响应。回应:[] ...
function addToCart() {
var product_id = 79;
var quantity = 1;
$.ajax({
url: 'index.php?route=checkout/cart/add',
type: 'post',
data: 'product_id=' + product_id + '&quantity=' + quantity,
dataType: 'json',
success: function (json) {
$('.success, .warning, .attention, .information, .error').remove();
if (json['redirect']) {
location = json['redirect'];
}
if (json['success']) {
$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
$('.success').fadeIn('slow');
$('#cart-total').html(json['total']);
$('html, body').animate({
scrollTop: 0
}, 'slow');
}
}
});
}
例如,如果我想使用URL:http://www.ninetheme.com/tender/index.php?route=checkout/cart/add&productid=52&quantity=1我得到同样的空回应。这是为什么? – 2013-02-12 17:28:22