0

I don't have problem with my like it is in the suggested question.

{
  "aaData": [
    {
      "id": "1",
      "reg_d": "2017-09-15 10:15:57",
      "fname": "Vishwas",
      "lname": "Jadav",
      "email": "vjadav@live.com"
    },
    {
      "id": "50",
      "reg_d": "2017-09-20 14:33:59",
      "fname": "testA",
      "lname": "testk",
      "email": "test5@gmail.com"
    },
    {
      "id": "51",
      "reg_d": "2017-09-20 14:36:18",
      "fname": "mvjh",
      "lname": "kgjk",
      "email": "teesth@jhk.com"
    }
  ],
  "draw": 5,
  "recordsTotal": 35,
  "recordsFiltered": 5
}

The Code I am using is:

<script type="text/javascript">
    $(document).ready(function() {
    $("#table1").dataTable({
      "preocessing" : true,
      "serverSide" : true,
      "sAjaxSource" : "dtable2.php",
      "columns" : [
        {"data" : "aaData.1"},
        {"data" : "aaData.3"},
        {"data" : "aaData.4"},
        {"data" : "aaData.5"},
        {"data" : "aaData.2"},
      ]
    });
    });
  </script>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">

  </head>
  <body>
    <table id="table1">
      <thead>
        <tr>
          <th>Id</th>
          <th>First Name</th>
          <th>Last Name</th>
          <th>Email</th>
          <th>Date</th>
        </tr>
      </thead>
    </table>
  </body>
  <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
  <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
  
</html>

but I am getting A warning in result

"DataTables warning (table id = 'table1'): Requested unknown parameter '0' from the data source for row 0"

I don't have problem with my like it is in the suggested question.

vishwas jadav
  • 199
  • 1
  • 4
  • 17
  • 1
    Possible duplicate of [DataTables warning: Requested unknown parameter '0' from the data source for row '0'](https://stackoverflow.com/questions/16539578/datatables-warning-requested-unknown-parameter-0-from-the-data-source-for-row) – StudioTime Sep 26 '17 at 10:21
  • @DarrenSweeney I tried the latest version but still the same warning. – vishwas jadav Sep 26 '17 at 10:28

2 Answers2

2

You try this code:

<script type="text/javascript">
$(document).ready(function() {
$("#table1").dataTable({
  "preocessing" : true,
  "serverSide" : true,
  "sAjaxSource" : "dtable2.php",
  "columns" : [
    {"data" : "id"},
    {"data" : "fname"},
    {"data" : "lname"},
    {"data" : "email"},
    {"data" : "reg_d"},
  ]
});
});

See more: Columns render

Nobita
  • 330
  • 1
  • 11
0

you are not sumbitting the correct form of data to the plugin in here,

"columns" : [
        {"data" : "aaData.1"},
        {"data" : "aaData.3"},
        {"data" : "aaData.4"},
        {"data" : "aaData.5"},
        {"data" : "aaData.2"},
      ]

for example : aaData.1 cannot be read by the plugin.

Check here too