【发布时间】:2011-12-05 01:39:44
【问题描述】:
我正在尝试从 ajax 调用回调到我的 ViewResult Index() 控制器操作,以根据下拉选择更新页面内容,但我的视图没有重新更新(重新渲染)。
我已经设置了断点,并且控制器中的 index() 操作正在按照从 ajax 'get' 调用的方式执行,并且模型正在传递给视图(视图中也遇到了断点)。
查看:
@* Contains code to build a webgrid and display data based on the model passed in... *@
@* Contains a couple of dropdowns for filtering *@
@*
Catch the select event from a dropdown and call back into the view to re-update page contents
for filter requests.
*@
<script type="text/javascript">
$("select").multiselect({
click: function (event, ui) {
$.ajax(
{ type: "GET",
url: '@Url.Action("Index","Data")',
data: { FilterRequest: (ui.checked ? 'checked' : 'unchecked') },
success: function () {
alert('hello again');
}
})
}
});
</script>
控制器:
// GET: /Data/
public ViewResult Index(string FilterRequest)
{
IList<DataModel> dataResult;
if (FilterRequest == null)
{ // Not a filter request so just update grid with full contents
dataResult = db.DataObjs.OrderByDescending(x => x.id).ToList();
}
else
{ // Filter request so update grid with filtered data
dataResult = db.DataObjs.Where(/*Build some filtered stuff here*/).OrderByDescending(x => x.id).ToList();
}
// Build some sub totals based on the resultset from above result set to display
// Other business logic number mashing here to display in other grids on the same view
return View(dataResult);
}
【问题讨论】:
标签: asp.net asp.net-mvc asp.net-mvc-3 jquery