2016-10-28 60 views
0

我使用不同的html頁面內容動態加載了一個popup div。 HTML頁面控件在div上成功顯示,但問題是,在使用$("#middlepart").load() 加載內容期間整個頁面刷新我想在不刷新asp.net中的頁面的情況下重新加載內容。下面 的代碼給出:在asp.net中加載div而不刷新頁面

<div class="popmiddlepart"> 
       <div class="type-benifit"> 
        <div class="subdivOne"> 
         <div class="fl-lt"> 
          <label>Type of Benefit</label> 
         </div> 
         <div class="fl-lt"> 
          <div id="ddlBenefitType" > 
          </div> 

         </div> 
         <div class="clearfix"></div> 
         <hr style="margin-bottom: 10px; margin-top: 10px;"> 
        </div> 
       </div> 


       <div id="relate-message-box-html" style="display: none"> 
        <i class="fa fa-info-circle" aria-hidden="true" style="color: red;"></i><strong></strong> 
        <span id="spnToolTipTexthtml"></span> 
       </div> 

       <div class="clearfix"></div> 
       <div id="middlepart" class="dynamic-content"> 
        <div class="middle-part"> 
         content goes here 
        </div> 
       </div> 

      </div> 

我更新的股利調用下拉onchange事件

$("#ddlBenefitType").relateSelectControl({ 
      selectControlDataSource: benefittypedata, 
      dataValueField: 'id', 
      dataTextField: 'text', 

      onchange: function (e) { 
       e.preventDefault(); 
       var selectedtype = $("#ddlBenefitType").getSelectControlText(); 

       if (selectedtype == 'Accommodation') { 
        var key = getQueryStringValue('id'); 
        $("#middlepart").load(baseUrl + "employee/accomodationdetails_ie.html?id=" + key); 
       } 

       if (selectedtype == 'Loan') { 
        var key = getQueryStringValue('id'); 
        $("#middlepart").load(baseUrl + "employee/loandetails_ie.html?id=" + key); 
       } 
      } 
     }); 
+3

使用Juery AJAX .. –

回答

1

嘗試$.get()。這是一個簡短的jQuery Ajax調用異步加載來自外部源的html。

像這樣的東西應該工作:

$.get(baseUrl + "employee/accomodationdetails_ie.html?id=" + key, function(data) { 
    $("#middlepart").html(data); 
});