Javascript:
$("#indexList").load('/Test/Index',{"id":"1","name":"测试"}, function (result) { //成功后执行。 } ); 或者 $.ajax({ type : 'post', url : '/Test/Index', data : { "id" : "1", "name" : "测试" }, dataType : 'text', success : function (result){ $('indexList').html(result); //成功后执行。 } });
Html-View:
<div id="indexList"> @{Html.RenderPartial("IndexPartial");} </div>
Html-PartialView:
@using Test.Models <table> <thead> <tr> <td>ID</td> <td>名称</td> </tr> </thead> <tbody> @{ foreach(test m in Model) { <tr> <td>@m.id</td> <td>@m.name</td> </tr> } } </tbody> </table>
Controller:
public ActionResult Index(string id, string name) { List<test> list = new List<test>(); if(Request.IsAjaxRequest()) { return PartialView("IndexPartial", list); } return View(list); }