簡體   English   中英

從子目錄刷新父窗口div

[英]Refreshing parent window div from child

我正在處理需要刷新父窗口的某些div的頁面,這是我的用例

  1. 用戶單擊添加到購物車按鈕,將彈出一個帶有添加的產品詳細信息的窗口。
  2. 我正在調用父窗口中包含的JS文件中定義的Java腳本方法。

從該函數中,我正在調用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM