我有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