您好我正在尝试在局部视图中填充WebGrid。显然一切都是正确的没有错误没有例外,但我的ajax调用失败。
我的代码(部分视图)
@using ThisController = MatterDict.Controllers.MatterDictController
@model IEnumerable<MatterDict.Models.MatterDictViewModel>
<div id="wgmatterDict">
@{
WebGrid displayGrid = new WebGrid(source: Model, ajaxUpdateContainerId: "wgmatterDict");
@displayGrid.GetHtml(columns: new[]
{
displayGrid.Column("LSC_Work_Type", header:"ETHNIC ORIGIN"),
displayGrid.Column("RULE_NO", header:"DESCRIPTION"),
displayGrid.Column("ACT_NO", header:"DESCRIPTION"),
displayGrid.Column("ACTION", header:"DESCRIPTION"),
displayGrid.Column("OPEN_FLAG", header:"DESCRIPTION"),
});
}
</div>
我在模型中获得结果,并且按预期运行。
我的Ajax脚本
$.ajax({
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({ WorkType: lsc_WorkType, Rule: rule, Act_No: act_No, ActionDesc: action }),
type: "POST",
@*url: '@Url.Action("getQueryResult")',*@
url: '@Url.Action("DisplayPartial")',
success: function (result) {
alert(result);
$("#wgmatterDict").html(result)
alert("successful");
},
error: function (xhr, ajaxOptions, thrownError) {
alert("unsuccessful call ");
}
});
这是一个警告:不成功的电话
我的控制器
public ActionResult DisplayPartial(string WorkType,int? RuleNo,int? Act_No,string ActionDesc)
{
return PartialView("DisplayPartial", getQueryResult(WorkType, RuleNo, Act_No, ActionDesc));
}
[HttpPost]
public IEnumerable<MatterDictViewModel> getQueryResult(string WorkType, int? RuleNo, int? Act_No, string ActionDesc)
{
IEnumerable<MatterDictViewModel> result = newOps.getQueryResult(WorkType, RuleNo, Act_No, ActionDesc);
return result;
}
我正在使用2个模型你能否建议是否有更好的方法来实现这一点。 任何帮助表示赞赏 谢谢