更新时间:2023-02-25 18:17:37
That's where Microsoft came out with the Ajax.ActionLink. That's one option; I personally like jQuery better, so I do something like:
$.ajax({
type: "get",
url: "@Url.Action("Partial", "Controller"),
success: function(d) {
/* d is the HTML of the returned response */
$("#SomeParentIDForSection").html(d); //replaces previous HTML with action
}
});
只需确保您的控制器返回局部视图:
Just make sure your controller returns a partial view:
public ActionResult Partial()
{
var model = ..
//init work
return PartialView(model);
}
有关更多信息和其他方法,请参见以下参考资料:
See these references for more information and some other approaches: