2014-01-14 38 views
1

我有一個包含項目列表的默認頁面。當我點擊那些我需要動態地追加數據頁面B到股利和應用重定向到頁面B.無法將數據追加到Div並重定向頁面

項目我網頁B '

加入這個div On Click事件我做以下動作在.js文件:

'$(document).on('click', '#selectConcept', function (node) { 
    var ncid = this.textContent.slice(6,25); 
    $.ajax({ 

     dataType: "json", 

     url: "http://txv-trmindexer01:8080/CommonTerminologyLeopardSearch/rest/getConceptByNcid/" + ncid, 

     error: function() { 
      alert("ERROR"); 
     }, 
     success: function (data) { 
      window.location.href = 'getfacets.html'; 
      for (var result = 0; result < finalSearchResults.length; result++) { 
       if (finalSearchResults[result].ncid == ncid) { 

        $("#selectedConceptitem").empty(); 
        var selectedconcept = "<p>" + "ncid: " + finalSearchResults[result].ncid + "," + "cid: " + finalSearchResults[result].cid + "</p>"; 

        $(selectedconcept).appendTo("#selectedConceptitem"); 


       } 
      } 

     } }); 
});' 

我能夠重定向頁面,但沒有附加到事業部。

誰能幫助我走出這個..

回答

0

我真的不知道,但我想新的頁面加載前的代碼運行。所以,你可以嘗試在onload事件時間

window.location.href = 'getfacets.html'; 
window.onload = function() { 
    for (var result = 0; result < finalSearchResults.length; result++) { 
     if (finalSearchResults[result].ncid == ncid) { 
      $("#selectedConceptitem").empty(); 
      var selectedconcept = "<p>" + "ncid: " + finalSearchResults[result].ncid + "," + "cid: " + finalSearchResults[result].cid + "</p>"; 
      $(selectedconcept).appendTo("#selectedConceptitem"); 
     } 
    } 
} 
0

的問題包在一個函數運行代碼:

只要你設置「window.location.href」屬性頁面瀏覽到您的頁面B,並且你放棄了獲取的數據。

你有兩個解決問題的方案:

  1. 使用單頁應用(SPA)應用方案,其中您可以爲您獲取的數據,其現在可以通過頁面中使用一個新的全球範圍乙

  2. 發送國家公民身份卡作爲查詢字符串參數頁面B和和實現服務呼叫和數據第B附加邏輯