我正在使用Shopify建立一個在線商店,並且在默認模板中遇到了一些我想修改我的需求的jQuery/Ajax代碼。Shopify post阿賈克斯添加到購物車成功消息在購物車頁面
function addToCartSuccess (jqXHR, textStatus, errorThrown){
$.ajax({
type: 'GET',
url: '/cart.js',
async: false,
cache: false,
dataType: 'json',
success: updateCartDesc
});
window.location = "/cart";
$('.add-cart-msg').hide().addClass('success').html('Item added to cart! <a href="/cart" title="view cart">View cart and check out »</a>').fadeIn('300');
}
我添加了window.location的行自己在想它會發布的購物車頁面上,但無濟於事消息。如果我刪除了該代碼,則當按下「添加到購物車」按鈕時,成功消息將發佈到產品頁面上,因此它可以在不做任何修改的情況下實際工作
我也試圖與一個POST命令來創建自己的功能,但真正我最好的猜測,因爲我沒有這個水平的jQuery的/阿賈克斯
function updateCartDesc (jqXHR, textStatus, errorThrown){
$.ajax({
type: 'POST',
url: '/cart',
async: false,
cache: false,
dataType: 'html',
success: function(){('.add-cart-msg').hide().addClass('success').html('Item added to cart! <a href="/cart" title="view cart">View cart and check out »</a>').fadeIn('300');
}
});
任何指點我在哪裏任何以往的經驗出錯了?教程,指南等將是美好的。謝謝
你想完成什麼? – Paul 2012-08-16 21:49:23
對不起,如果我沒有說清楚。一旦點擊添加到購物車按鈕,就會在頁面上顯示一條消息,說明某件商品已添加到購物車。我想修改它,以便導航到不同的頁面(購物車頁面)並在那裏添加消息,但是我的更改僅在不顯示消息的情況下打開購物車頁面。 – Bantros 2012-08-16 22:29:55