javascript - 我有一个提交给自身的表单,导致页面刷新。我正在尝试使该代码进行 ajax 调用,因此只有一些页面刷新
问题描述
此代码将购物车的信息提交给它自己。刷新整个页面,但更新可用性和数量等值。(不包括一些代码)我试图让它成为一个类似于位于下面的代码的 ajax 调用。
<form action="${URLUtils.httpsContinue()}" method="post" name="${pdict.CurrentForms.cart.htmlName}" id="cart-items-form">
<fieldset>
<legend class="visually-hidden">Your cart</legend>
<iscomment>This button is hidden but required to ensure that update cart is called whenever the "enter" key is pressed in an input field</iscomment>
<button class="visually-hidden" type="submit" value="${pdict.CurrentForms.cart.updateCart.htmlName}" name="${pdict.CurrentForms.cart.updateCart.htmlName}"></button>
<table id="cart-table" class="item-list">
<thead>
<tr>
<th class="section-header" colspan="2">${Resource.msg('global.product','locale',null)}</th>
<isif condition="${dw.system.Site.getCurrent().getCustomPreferenceValue('enableStorePickUp')}">
<th class="section-header">${Resource.msg('cart.store.deliveryoptions','storepickup',null)}</th>
</isif>
<th class="section-header quantity" colspan="2">${Resource.msg('global.qty','locale',null)}</th>
<th class="section-header price">${Resource.msg('global.price','locale',null)}</th>
<th class="section-header header-total-price">${Resource.msg('global.totalprice','locale',null)}</th>
</tr>
</thead>
<tbody>
<iscomment> LOOP TO SEPARATE DIFFERENT SHIPMENTS ex: Gift Registry Shipments Etc.</iscomment>
<isloop items="${pdict.CurrentForms.cart.shipments}" var="Shipment" status="loopstate">
<isloop items="${Shipment.items}" alias="FormLi" status="loopstate">
<isset name="lineItem" value="${FormLi.object}" scope="page" />
<isscript>
var isInWishList = false; if (pdict.WishList) { var wishListItems = pdict.WishList.items; var wishListItemsSize = wishListItems.size(); for each( var wishListItem in wishListItems ) { if (lineItem.productID == wishListItem.product.ID) { isInWishList =
true; break; } } }
</isscript>
<iscomment> Skip bonus-choice products in first pass. </iscomment>
<isif condition="${lineItem.bonusDiscountLineItem == null && (lineItem.productID == null || lineItem.productID != ptimeHelper.getNextDayProductID()) && !lineItem.custom.upsellItem}">
<tr class="cart-row" data-uuid="${lineItem.getUUID()}">
<td class="item-image">
<isset name="image" value="${new ProductImage('small', lineItem.product, 0)}" scope="page" />
<isif condition="${lineItem.product != null && image != null}">
</form>
我需要这样的 ajax 调用:有什么建议吗?我可以将其从表单中取出并以另一种方式存储数据吗?
progress.show($('.search-result-items'));
refineUrl = refineUrl.replace('?', '?format=ajax&');
$('#main').load(refineUrl, function () {
compareWidget.init();
productTile.init();
progress.hide();
解决方案
推荐阅读
- javascript - 函数返回从 socket.on (socket.io) 得到的结果
- ios - 如何在 Swift 中使用重音字符加密字符串
- flutter - 将容器高度调整为行中子项的最大高度
- python - Pandas 用户指南中的困惑
- angular - 从 Symfony 中的 Restful API 以角度检索 JWT 令牌
- swift - 在 2 CGPoint 之间画线而不使用很多 addLine
- flutter - 如何处理代码?
- javascript - 如何解决此警告 - 警告:validateDOMNesting(...):不能显示为. 下面是我的代码
- visual-c++ - 如何将整数文字指定为 WORD?
- android - 如何在 xml 数据绑定中使用表情符号?