我想将部分视图返回为html,所以我可以在div中将其渲染为html,但是它无法正常工作,我无法找到为什么其无法正常工作的问题,这是我的代码。
function getPartial(id) {
$.ajax({
type: "POST",
url: "/Home/GetPartial",
contentType: "application/html",
data: { ID: id },
success: function (response) {
$(".ui-layout-east").html(response);
alert(response);
}
});
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我这样做。
[HttpPost]
public ActionResult GetPartial(int ID)
{
var gopal = DataAccess.DataAccess.FillDetailByID(ID);
return PartialView("parent", gopal);
}
Run Code Online (Sandbox Code Playgroud)
但是当我返回为json时,则无法正常工作,请帮助我解决该问题。以下是我要退回的我的部分资料。
@model WebTreeDemo.Models.Employee
<div id="widget">
<div id="x">
@using (Html.BeginForm("Home", "Update", FormMethod.Post))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.EmpCode, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => …Run Code Online (Sandbox Code Playgroud)