我是MVC,jquery和DataTables的菜鸟.当我点击F5构建并在本地启动站点进行开发/调试时,我得到一个Microsoft Visual Studio警告对话框:
JavaScript运行时错误:对象不支持属性或方法'dataTable'
我正在使用VS 2012和MVC 4项目.我使用NuGet包管理器来安装\ update jQuery 1.8.3和jquery.datatables 1.9.4.这是我的Index.cshtml视图代码:
<script src="@Url.Content("~/Scripts/jquery-1.8.3.js")" type="text/javascript"> </script>
<script src="@Url.Content("~/Scripts/DataTables-1.9.4/media/js/jquery.dataTables.js")" type="text/javascript"></script>
<script>
$(document).ready(function () {
$('#table_id').dataTable({
});
});
</script>
<table id="table_id" class="display">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
这似乎是一个引用问题,但我没有尝试解决问题!
我搜索了博客,但无法找到答案,或者可能了解需要更改的内容.我们将非常感谢您的直接答复!
谢谢!