最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Typeerror D is undefined Jquery Datatables - Stack Overflow

programmeradmin1浏览0评论

I have the following code that is suppossed to generate report using datatables. But it keeps on failing giving me the following jquery datatbles error :

TypeError: d is undefined


...=f.nextSibling}else{d=b.anCells;f=0;for(b=d.length;f<b;f++)a(d[f])}return{data:e...

Below is my code that is supposed to generate the view , currently I get only a blank

<!DOCTYPE html>
<html lang="en">
    <head>
        <!--

        -->
        <meta charset="utf-8">
        <title>Care-tech System</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="Out patient Hospital Management System.">
        <meta name="author" content="Harris Samuel Dindi">
    </head>
    <body>
        <table id="test_trial" class="test_trial">
            <thead>
                <tr></tr>
            </thead>
            <tbody>
                <tr></tr>
            </tbody>
        </table>
    </body>
</html>

<script type="text/javascript" src=".11.1.min.js"></script>
<script type="text/javascript" src=".10.5/js/jquery.dataTables.min.js"></script>

<link href='.10.5/css/jquery.dataTables.css' rel='stylesheet'>



<script type="text/javascript">
    $(document).ready(function () {

        $("#test_trial").DataTable({
            stateSave: true,
            "bautoWidth": false,
            "aoColumns": [
                {"sTitle": "Commodity No", "mData": "modity_id"},
                {"sTitle": "Commodity Name.", "mData": "modity_name"

                },
                {"sTitle": "Strength", "mData": "strength"},
                {"sTitle": "Commodity code", "mData": "modity_code"},
                {"sTitle": "Type.", "mData": "modity_type"},
                {"sTitle": "Commodity unit", "mData": "modity_unit"},
                {"sTitle": "Max Stock", "mData": "max_stock"},
                {"sTitle": "Min sTOCK", "mData": "min_stock"},
                {"sTitle": "Remarks", "mData": "remarks"},
            ],
            "bDeferRender": true,
            "bProcessing": true,
            "bDestroy": true,
            "bLengthChange": true,
            "iDisplayLength": 20,
            "sAjaxDataProp": "",
            "sAjaxSource": '<?php echo base_url() . "pharmacy/modity_managements"; ?>',
            "aaSorting": [[2, "desc"]]

        });

    });
</script>

How can I do away with the error?

I have the following code that is suppossed to generate report using datatables. But it keeps on failing giving me the following jquery datatbles error :

TypeError: d is undefined


...=f.nextSibling}else{d=b.anCells;f=0;for(b=d.length;f<b;f++)a(d[f])}return{data:e...

Below is my code that is supposed to generate the view , currently I get only a blank

<!DOCTYPE html>
<html lang="en">
    <head>
        <!--

        -->
        <meta charset="utf-8">
        <title>Care-tech System</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="Out patient Hospital Management System.">
        <meta name="author" content="Harris Samuel Dindi">
    </head>
    <body>
        <table id="test_trial" class="test_trial">
            <thead>
                <tr></tr>
            </thead>
            <tbody>
                <tr></tr>
            </tbody>
        </table>
    </body>
</html>

<script type="text/javascript" src="http://code.jquery./jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="http://cdn.datatables/1.10.5/js/jquery.dataTables.min.js"></script>

<link href='http://cdn.datatables/1.10.5/css/jquery.dataTables.css' rel='stylesheet'>



<script type="text/javascript">
    $(document).ready(function () {

        $("#test_trial").DataTable({
            stateSave: true,
            "bautoWidth": false,
            "aoColumns": [
                {"sTitle": "Commodity No", "mData": "modity_id"},
                {"sTitle": "Commodity Name.", "mData": "modity_name"

                },
                {"sTitle": "Strength", "mData": "strength"},
                {"sTitle": "Commodity code", "mData": "modity_code"},
                {"sTitle": "Type.", "mData": "modity_type"},
                {"sTitle": "Commodity unit", "mData": "modity_unit"},
                {"sTitle": "Max Stock", "mData": "max_stock"},
                {"sTitle": "Min sTOCK", "mData": "min_stock"},
                {"sTitle": "Remarks", "mData": "remarks"},
            ],
            "bDeferRender": true,
            "bProcessing": true,
            "bDestroy": true,
            "bLengthChange": true,
            "iDisplayLength": 20,
            "sAjaxDataProp": "",
            "sAjaxSource": '<?php echo base_url() . "pharmacy/modity_managements"; ?>',
            "aaSorting": [[2, "desc"]]

        });

    });
</script>

How can I do away with the error?

Share Improve this question asked Jul 26, 2015 at 15:55 H DindiH Dindi 1,5528 gold badges39 silver badges71 bronze badges 2
  • You're using an outdated version of Data Tables. Use the latest to begin with. – lshettyl Commented Jul 26, 2015 at 16:34
  • 2 Start by referencing the non-minified datatables, i.e. change the source of the second script tag to be cdn.datatables/1.10.5/js/jquery.dataTables.js - this should at least give you a bit more information about what variable is undefined and where it is in the datatables source. – hgcummings Commented Jul 26, 2015 at 16:35
Add a ment  | 

2 Answers 2

Reset to default 4

TypeError: d is undefined means your server-side php endpoint URL (pharmacy/modity_managements) returns no data to the grid. Try to debug your php response.

Ishettyl gave an answer that is partly correct. The Data Table version is current, but the table properties that are being utilized are from the legacy edition of Data Tables. Changing all of your table properties to the 1.10.5 version should fix your issue. (example: change "mData" to "data", ect.)

发布评论

评论列表(0)

  1. 暂无评论