2012-12-21 29 views
0

我正在使用MVC3應用程序中的Asp.NET和kendo控件進行輔導門戶網站。我有一個名爲AddStudents一些視圖的按鈕。該按鈕的onClick的局部視圖呈現,並把具有該按鈕視圖的內容。用AJAX調用的結果替換視圖的內容

學生表單出現在這個視圖上,但它自己的內容也出現在同一頁面上,我用AJAX調用了jQuery來完成所有這些。我想替換具有局部視圖的傳入內容的視圖的本發明的內容。

$("#render").click(function() { 
    alert("chawaaaaaa!"); 
    $.ajax({ 
     url: "AddStudentsPartial", 
     type: 'GET', 
     cache: false, 
     success: function (result) { 
      alert(result); 
      $('#partial').html(result); 
     } 
    }); 
}); 

這就是我的按鈕點擊AJAX功能。任何人都可以幫我解決這個小問題嗎?

回答

0

要麼你更換觀點含量結果內容:

success: function (result) { 
     alert(result); 
     $('#partial').html($(result).html()); 
    } 

,或者您有孔的結果替換孔觀點:

success: function (result) { 
     alert(result); 
     $('#partial').replaceWith(result); 
    } 
0

您可以使用jQuery的load方法來做到這一點。

<script type="text/javascript"> 
$(function(){ 
    $("#render").click(function(){ 
     $("#partial").load("AddStudentsPartial") 
    }) 
}); 
</script>