jquery数据表json数据未绑定?mvc4
我试着这样做,但有点不对劲,我无法前进 我的视图代码:jquery数据表json数据未绑定?mvc4,jquery,json,asp.net-mvc-4,Jquery,Json,Asp.net Mvc 4,我试着这样做,但有点不对劲,我无法前进 我的视图代码: <html> <head> <script src="@Url.Content("~/Scripts/jquery-2.1.0.js")" type="text/javascript"> </script> <script src="@Url.Content("~/Scripts/jquery.dataTables.js")" type="text/ja
<html>
<head>
<script src="@Url.Content("~/Scripts/jquery-2.1.0.js")" type="text/javascript"> </script>
<script src="@Url.Content("~/Scripts/jquery.dataTables.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/index.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/demo_page.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/demo_table.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function () {
debugger;
alert("dfdfd");
$('#myDataTable').dataTable( {
"bServerSide": true,
"sAjaxSource": "Home/AjaxHandler",
"bProcessing": true,
"aoColumns": [
{
"sName": "ID",
"bSearchable": false,
"bSortable": false,
"fnRender": function (oObj) {
return '<a href=\"Details/' +
oObj.aData[0] + '\">View</a>';
alert(oObj);
}
},
{ "sName": "COMPANY_NAME" },
{ "sName": "ADDRESS" },
{ "sName": "TOWN" }
]
});
});
</script>
</head>
<body>
<table id="myDataTable" class="display">
<thead>
<tr>
<th>ID</th>
<th>Company name</th>
<th>Address</th>
<th>Town</th>
</tr>
</thead>
</table>
</body>
更新:
我的错误:还编辑了上面的视图零件检查
'iexplore.exe' (Script): Loaded 'Script Code (Windows Internet Explorer)'.
Unhandled exception at line 3398, column 4 in http://localhost:49205/Scripts/jquery-2.1.0.js
0x800a01b6 - Microsoft JScript runtime error: Object doesn't support this property or method
Unhandled exception at line 39, column 7 in http://localhost:49205/Scripts/jquery.dataTables.js
0x800a1391 - Microsoft JScript runtime error: 'jQuery' is undefined
Unhandled exception at line 2, column 1 in http://localhost:49205/Scripts/index.js
0x800a138f - Microsoft JScript runtime error: Object expected
问候终于得到了我并不完全满意的解决方案。我使用的是j-query 2.1,当我使用它时,我得到了j-query未定义的异常但现在我尝试使用j-query 1.4,它现在运行良好:)
感谢您的意见,我不确定是
“aoColumns”
还是“aoColumnDefs”
?我的代码甚至没有调用控制器中的代码:“sAjaxSource”:“Home/AjaxHandler”。任何其他方式。如果你知道任何更好的链接,我可以通过其他方式查看这些链接。你是否尝试删除这些链接?尝试一次并检查表是否加载了数据。这样就可以在列定义中隔离问题。我看到的唯一问题是sEcho为null。试着给它赋值。检查参数Yes trued,但问题开始于此点$(“#myDataTable”)。dataTable({.数据完全正确。我面临的错误:0x800a01b6中第113行第29列出现未处理的异常-Microsoft JScript运行时错误:对象不支持此属性或方法请使用问题上的编辑链接添加其他信息。回答后按钮应仅用于问题的完整答案。my pro这个问题现在已经解决了。我希望通过这种方式解决我的问题。我认为这会对某人有所帮助并发布。我觉得这就是答案,我错了吗?
{
"sEcho":null,
"iTotalRecords":97,
"iTotalDisplayRecords":3,
"aaData":[
["1","Microsoft","Redmond","USA"],
["2","Google","Mountain View","USA"],
["3","Gowi","Pancevo","Serbia"]
]
}
'iexplore.exe' (Script): Loaded 'Script Code (Windows Internet Explorer)'.
Unhandled exception at line 3398, column 4 in http://localhost:49205/Scripts/jquery-2.1.0.js
0x800a01b6 - Microsoft JScript runtime error: Object doesn't support this property or method
Unhandled exception at line 39, column 7 in http://localhost:49205/Scripts/jquery.dataTables.js
0x800a1391 - Microsoft JScript runtime error: 'jQuery' is undefined
Unhandled exception at line 2, column 1 in http://localhost:49205/Scripts/index.js
0x800a138f - Microsoft JScript runtime error: Object expected