我正在尝试使用 AJAX 调用按钮单击来刷新部分视图中的网格。但是按钮的单击方法无法正常工作。
以下代码片段是我用来执行的代码
查询
<script type="text/javascript">
$(document).ready(function () {
$("#fromDate").datepicker({
changeMonth: true,
changeYear: true
});
$("#toDate").datepicker({
changeMonth: true,
changeYear: true
});
});
//function buttonClick() {
$("#btnSearch").click($.ajax({
url: 'Report/SearchGrid',
type: "POST",
success: function (html) {}
}));
//}
</script>
剃刀代码
<input type="button" value="Search" id="btnSearch" onclick= "buttonClick();" style="width: 90px; border: solid 1px #1570a6; background-color: #1570a6; color: #FFFFFF; font-weight: 100;" />
控制器代码
public ActionResult SearchGrid(ExpenseReportModel model)
{
ExpenseReportModel expModel = new ExpenseReportModel();
expModel.ExpenseList = GetExpenseList();
expModel.ExpenseFromDate = Convert.ToDateTime(model.ExpenseFromDate);
expModel.ExpenseToDate = Convert.ToDateTime(model.ExpenseToDate);
return PartialView("_GridData", expModel.ExpenseList);
}