[英]Refreshing parent window div from child
我正在處理需要刷新父窗口的某些div的頁面,這是我的用例
從該函數中,我正在調用ajax調用,並希望使用ajax調用從服務器發送的內容中替換該div內容,這是方法
function updateAllotmentQtySection(){
if($('#isProductAllotment').length > 0){
var allotmentEntryCode=$("#allotmentEntryCode").val();
var productcode=$("#productCodePost").val();
$.ajax({
type: "GET",
url: "/storefront/cart/getProductedAllotment/?productCode="+productcode+"&allotmentEntryCode="+allotmentEntryCode,
success: function(response) {
//alert(response);
$("#productAllotmentQtyDiv").html(response);
}
});
}
這是我要更新的Div部分
<div id="productAllotmentQtyDiv">
<c:choose>
<c:when test="${not empty productAllotment}">
<select name="qty" id="qty" class="productDetailsSelect">
<c:forEach items="${productAllotmentQty}" var="productAllotmentQty">
<option value="${productAllotmentQty}">${productAllotmentQty}</option>
</c:forEach>
</select>
<input type="hidden" name="allotmentEntryCode" id="allotmentEntryCode" value="${productAllotment.code}" />
<input type="hidden" name="isProductAllotment" id="isProductAllotment" value="true"/>
</c:when>
<c:otherwise>
<c:when test="${not empty editPersonalization}">
<input style="width: 46px;" type="text" size="1" id="qty"
name="qty" value="${quantity}" readonly="readonly" />
</c:when>
<c:otherwise>
<input style="width: 46px;" type="text" size="1" id="qty"
name="qty" value="${quantity}" />
</c:otherwise>
</c:otherwise>
</c:choose>
</div>
我正在從服務器中發送與div內相同的內容,甚至我也能夠在Alert標簽下看到正確的響應,但是不確定div的確切位置在哪里,因為div不會更新,而僅顯示以前的值
使用window.opener
從子級在父級上下文中調用函數:
window.opener.updateAllotmentQtySection();
(假設updateAllotmentQtySection()存在於父級的全局名稱空間中)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.