我正在尝试将 jQuery DataTables 插件集成到 ASP.Net MVC 项目中。我在这里按照示例进行操作。当我在测试项目中仅运行示例代码时,一切正常。但是当我尝试在我的真实应用程序中调试它时,它AjaxHandler
甚至没有被执行。我错过了什么吗?
这是调用 jQuery 代码:
$(document).ready(function () {
$('#myDataTable').dataTable({
"bServerSide": true,
"sAjaxSource": "/UX/AjaxHandler",
"bProcessing": true,
"aoColumns": [
{
"sName": "ID",
"bSearchable": false,
"bSortable": false,
"fnRender": function (oObj) {
return '<a href=\"Details/' + oObj.aData[0] + '\">View</a>';
}
},
{ "sName": "NAME" },
{ "sName": "ADDRESS" },
{ "sName": "TOWN" },
]
});
});
</script>
然后是我的处理程序;
public ActionResult AjaxHandler(jQueryDataTableParamModel param)
{
return Json(new
{
sEcho = param.sEcho,
iTotalRecords = 97,
iTotalDisplayRecords = 3,
aaData = new List<string[]>() {
new string[] {"1", "Microsoft", "Redmond", "USA"},
new string[] {"2", "Google", "Mountain View", "USA"},
new string[] {"3", "Gowi", "Pancevo", "Serbia"}
}
},
JsonRequestBehavior.AllowGet);
}