[英]Why does using alert in Shopify cart/add API only add product in cart for firefox browser?
I want to add a product in cart page of my Shopify website.I am using Shopify cart/add.js API for adding a product in cart.It's working in Google Chrome browse.But for Firefox it's not working.How can i do it in Mozilla Firefox using same API and withot using alert box? 我想在Shopify网站的购物车页面添加一个产品。我正在使用Shopify cart / add.js API在购物车中添加产品。它正在谷歌Chrome浏览器中工作。但是对于Firefox它没有用。我怎么能这样做在Mozilla Firefox中使用相同的API和withot使用警告框?
I am performing event on click of Add to cart button 我点击添加到购物车按钮进行活动
<button class="btn" id="add_raffle">
<span id="AddToCartText-product-template">Add to cart</span>
</button>
Form to post 表格发布
<form action="/cart/add" id="raffle_prod">
<input type = "hidden" name="id" value = "13597453582389" id="raffle_variant">
<input type = "hidden" name="quantity" value = "1" >
<input type="submit" style="display:none" id="raffle_submit">
Jquery Code Jquery代码
$('#add_raffle').click(function(event){
var FIREFOX = /Firefox/i.test(navigator.userAgent);
if (FIREFOX) {
$('#raffle_submit').trigger("click");
alert('Raffle tickets added. Thanks!');
} else {
var dataString = $('#raffle_variant').serialize();
jQuery.post('/cart/add.js', dataString);
alert('Raffle tickets added. Thanks!');
}
});
This code is working for Google chrome. 此代码适用于Google Chrome。
But for Firefox following code is not working.I need to post a form and use alert after request then product is adding in cart. 但对于Firefox,代码不起作用。我需要发布一个表单并在请求后使用警报然后产品添加到购物车中。
I want to avoid alert and want to use same api code as i do for google chrome. 我想避免提醒,并希望使用与谷歌浏览器相同的api代码。
Check that if
statement in your jQuery code. 检查jQuery代码中的
if
语句。
Fixed: 固定:
$('#add_raffle').click(function(event){
var dataString = $('#raffle_variant').serialize()
jQuery.post('/cart/add.js', dataString)});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.