简体   繁体   English

从子目录刷新父窗口div

[英]Refreshing parent window div from child

I am working on a page where i need to refresh certain div of parent window and here is my use case 我正在处理需要刷新父窗口的某些div的页面,这是我的用例

  1. User click on add to cart button and a pop-up will come with added product details. 用户单击添加到购物车按钮,将弹出一个带有添加的产品详细信息的窗口。
  2. I am calling a java-script method defined in a JS file which is included in parent window. 我正在调用父窗口中包含的JS文件中定义的Java脚本方法。

from that function i am calling a ajax call and want to replace that div content from the content being sent from the server using ajax call and here is the method 从该函数中,我正在调用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);
         }
    });

  }

Here is the Div section which i am trying to update 这是我要更新的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>

I am sending the same content from the server which i inside the div and even i am able to see the correct response under the alert tag but not sure where exactly is wrong part as the div is not getting updated but only showing the previous values 我正在从服务器中发送与div内相同的内容,甚至我也能够在Alert标签下看到正确的响应,但是不确定div的确切位置在哪里,因为div不会更新,而仅显示以前的值

Use window.opener to call a function in the parent's context from the child: 使用window.opener从子级在父级上下文中调用函数:

window.opener.updateAllotmentQtySection();

(assuming updateAllotmentQtySection() exists in the global namespace in the parent) (假设updateAllotmentQtySection()存在于父级的全局名称空间中)

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

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