我正在使用DataTables.net和MVC 5并返回JsonResult。页面显示表结构但未加载任何数据。请查看我的代码

时间:2021-07-19 14:29:19

I did everything like adding jquery before datatables.js, changing settings of datatable. Still it's not working. Please help me out:

我做了一切,比如在datatables.js之前添加jquery,更改数据表的设置。它仍然没有用。请帮帮我:

<script type="text/javascript">
    setTimeout(function () {
        location = ''
    }, 60000)
    $(function () {
       
        $('#datatable').DataTable({
            "ajax": "EmployeeDetails",
            "aoColumns": [
               { "mData": "EmpID" },
               { "mData": "EmpName" },
               { "mData": "EmpMobile" },
               { "mData": "OSName" },
               { "mData": "OSVersion" },
               { "mData": "BrowserName" },
               { "mData": "Platform" },
               { "mData": "DeviceUID" }
            ]
        });

    });
</script>
<table id="datatable" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Employee ID</th>
                    <th>Name</th>
                    <th>Mobile</th>
                   
                    <th>OS Name</th>
                    <th>OS Version</th>
                    <th>Browser Name</th>
                     <th>Platform</th>
                    <th>Device UID</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>Employee ID</th>
                    <th>Name</th>
                    <th>Mobile</th>
                   
                    <th>OS Name</th>
                    <th>OS Version</th>
                    <th>Browser Name</th>
                    <th>Platform</th>
                    <th>Device UID</th>
                </tr>
            </tfoot>
        </table>
    </div>
</div>

I'm returning json string using EmployeeDetails method which is coreect

我正在使用EmployeeDetails方法返回json字符串,这是coreect

1 个解决方案

#1


finally i found the solution , actually i included jquery twice in bundle and on page too! removing from bundle did work fro me! Thanks for suggestions. Also i applied datatables to default MVC table structure and it worked too!

最后我找到了解决方案,实际上我在包中和页面上也包含了两次jquery!从捆绑中取出确实对我有用!谢谢你的建议。此外,我将数据表应用于默认的MVC表结构,它也工作!

#1


finally i found the solution , actually i included jquery twice in bundle and on page too! removing from bundle did work fro me! Thanks for suggestions. Also i applied datatables to default MVC table structure and it worked too!

最后我找到了解决方案,实际上我在包中和页面上也包含了两次jquery!从捆绑中取出确实对我有用!谢谢你的建议。此外,我将数据表应用于默认的MVC表结构,它也工作!