简体   繁体   English

在同一页面上提交表格

[英]Submit form while staying on same page

I have the following setup: https://jsfiddle.net/uosLke60/我有以下设置: https ://jsfiddle.net/uosLke60/

 input.Add_To_Cart_Button { background-color: #000; color: #fff; border: none; font: inherit; cursor: pointer; font-size: 13px; margin-bottom: 40px; width: 120px; -webkit-appearance: none; border-radius: 0; }
 <div class="Product_Card_Button"> <form method="post" action="/cart/add"> <quantity-input class="quantity" style="width: 120px; min-height: 25.4px; display: inline-flex;"> <button class="quantity__button no-js-hidden" name="minus" type="button"> - </button> <input class="quantity__input" type="number" name="quantity" id="quantity" min="1" value="1" style="text-align: center;"> <button class="quantity__button no-js-hidden" name="plus" type="button">+</button> </quantity-input> <br> <input type="submit" value="Add to cart" class="Add_To_Cart_Button" /> </form> </div>

When the add to cart button is pressed, the page refreshes.当按下添加到购物车按钮时,页面会刷新。 How can I adjust it so that the product is added to cart without the page refresh?如何调整它以便在不刷新页面的情况下将产品添加到购物车? Any suggestions would be helpful.任何的意见都将会有帮助。 Thanks.谢谢。

您应该使用 Ajax 来实现这一点,因此可以更新网页的某些部分,而无需重新加载整个页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM