Requested unknown parameter / JSON / data

Requested unknown parameter / JSON / data

HebeldarkHebeldark Posts: 9Questions: 2Answers: 0

Hello

i'm new with this addon.

i have already my ajax call that returned me a json data
this is a console.log about data returned:

{data: "[{"clipwd_id":102122,"clipwd_idbad":"22222222","cl…clipwd_date":"2017-08-01","clipwd_pwd":"111111"}]", data1: "[{"params_id":1,"params_code":"importPWDdate","par…rtation des pwd","params_valeur":"18\/10\/2017"}]", recordsTotal: 10, recordsFiltered: 10, isError: false, …}
Alert : "success"
Origin : "MySQL"
data :
"[{"clipwd_id":102122,"clipwd_idbad":"22222222","clipwd_date":"2016-09-16","clipwd_pwd":"111111"},{"clipwd_id":101892,"clipwd_idbad":"22222222","clipwd_date":"2017-03-13","clipwd_pwd":"111111"},{"clipwd_id":102024,"clipwd_idbad":"22222222","clipwd_date":"2016-06-09","clipwd_pwd":"111111"},{"clipwd_id":100867,"clipwd_idbad":"22222222","clipwd_date":"2017-01-18","clipwd_pwd":"111111"},{"clipwd_id":103255,"clipwd_idbad":"22222222","clipwd_date":"2016-09-19","clipwd_pwd":"111111"},{"clipwd_id":101609,"clipwd_idbad":"22222222","clipwd_date":"2016-07-18","clipwd_pwd":"111111"},{"clipwd_id":102366,"clipwd_idbad":"22222222","clipwd_date":"2016-11-23","clipwd_pwd":"111111"},{"clipwd_id":102946,"clipwd_idbad":"22222222","clipwd_date":"2017-04-25","clipwd_pwd":"111111"},{"clipwd_id":102428,"clipwd_idbad":"22222222","clipwd_date":"2017-09-25","clipwd_pwd":"111111"},{"clipwd_id":102676,"clipwd_idbad":"22222222","clipwd_date":"2017-08-01","clipwd_pwd":"111111"}]"
data1 :
"[{"params_id":1,"params_code":"importPWDdate","params_description":"date de la derni\u00e8re importation des pwd","params_valeur":"18\/10\/2017"}]"
isError  :false
recordsFiltered : 10
recordsTotal : 10

i'm using $().DataTable() in my sucess ajax return to load data in datatable

 $('#Example').DataTable( {
                        "data": data['data'],
                        "columns": [
                            { "data": "clipwd_id" },
                            { "data": "clipwd_idbad" },
                            { "data": "clipwd_date" },
                            { "data": "clipwd_pwd" } ]
                              } );

but i have a error
DataTables warning: table id=Example - Requested unknown parameter 'clipwd_id' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4

i add recordFiltered and recrdTotal to see but same issue

i don't see my error
when i used this code

 $('#Example').DataTable( {
                        "data": data,
                        "columns": [
                            { "data": "clipwd_id" },
                            { "data": "clipwd_idbad" },
                            { "data": "clipwd_date" },
                            { "data": "clipwd_pwd" } ]
                              } );

i have no error but no data anyway :smile:

HTML Code:

<table id="Example" class="table display">
<thead>
            <tr>
                <th>ID</th>
                <th>Client</th>
                <th>Date</th>
                <th>Password</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>ID</th>
                <th>Client</th>
                <th>Date</th>
                <th>Password</th>
            </tr>
        </tfoot>

</table>

Thx for any answer !

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin
    Answer ✓

    Can you run your table through the debugger so I can get a trace and see exactly how it is setup.

    Thanks,
    Allan

  • HebeldarkHebeldark Posts: 9Questions: 2Answers: 0

    i'm sorry but i don't know how to use this debugger.

    i copy/paste the code in console but i have a undefined response

    i paste console log to see you what my ajax call return to me; so the json structure

    need i to insert this function in ajax sucess section ?

  • HebeldarkHebeldark Posts: 9Questions: 2Answers: 0
    edited October 2017
  • HebeldarkHebeldark Posts: 9Questions: 2Answers: 0

    ok i see what the problem is;

    datatable doesn't see my rows correctly

    datatable return to me 961 rows with 1 row = 1 character

    but i use the same structure of json that examples in website..

  • HebeldarkHebeldark Posts: 9Questions: 2Answers: 0
    edited October 2017

    this is the page online

    debug.datatables.net/ayepof

  • kthorngrenkthorngren Posts: 20,296Questions: 26Answers: 4,768

    It looks like your data is encapsulated in a string:
    {data: "[{"clipwd_.......

    the " in from of the [ indicates the data is a string not an array of object data. This page explains how to structure your data:
    https://datatables.net/manual/data/#Data-source-types

    Kevin

  • HebeldarkHebeldark Posts: 9Questions: 2Answers: 0

    Thx

    i see that but i use the function json_encode from PHP

    i see this page about array or object
    and my php page send me a json object

    $data['Data0'] =  $bdd_connexionMYSQL->select($requete0); 
    $data['Data1'] =  $bdd_connexionMYSQL->select($requete1);  
    $data['test'] = $test;
    $data['isError'] =  false;
    $data['Origin'] =  'MySQL';
    $data['Alert'] =  'success';
    
    $reponse =   json_encode($data);
    

    i tried to create a json in a json like this:

    $test["dataTEST"] =  $bdd_connexionMYSQL->select($requete0);
    $test["draw"] = 1;
    $test["recordsTotal"] = 10;
     $test["recordsFiltered"] = 10;
    
    $data['Data0'] =  $bdd_connexionMYSQL->select($requete0); 
     $data['Data1'] =  $bdd_connexionMYSQL->select($requete1);  
     $data['test'] = $test;
     $data['isError'] =  false;
    $data['Origin'] =  'MySQL';
    $data['Alert'] =  'success';
    
    $reponse =   json_encode($data);
    

    and in my page

    $('#Example').DataTable( {
     "data": data['test'],
     "datasrc" : 'dataTEST',
    ...
    
    

    but the debugger send me always the same response about initialisation options

    {
        "data": {
            "dataTEST": "[{\"clipwd_id\":100150,\"clipwd_idbad\":\"13587153\",\"clipwd_date\":\"2017-04-25\",\"clipwd_pwd\":\"319925\"},{\"clipwd_id\":101791,\"clipwd_idbad\":\"41462818\",\"clipwd_date\":\"2017-08-01\",\"clipwd_pwd\":\"049879\"},{\"clipwd_id\":100127,\"clipwd_idbad\":\"13118576\",\"clipwd_date\":\"2017-03-13\",\"clipwd_pwd\":\"574232\"},{\"clipwd_id\":101339,\"clipwd_idbad\":\"34456848\",\"clipwd_date\":\"2017-04-25\",\"clipwd_pwd\":\"468177\"},{\"clipwd_id\":101085,\"clipwd_idbad\":\"30420869\",\"clipwd_date\":\"2017-04-21\",\"clipwd_pwd\":\"664553\"},{\"clipwd_id\":103581,\"clipwd_idbad\":\"79656774\",\"clipwd_date\":\"2017-05-11\",\"clipwd_pwd\":\"740191\"},{\"clipwd_id\":102062,\"clipwd_idbad\":\"45919068\",\"clipwd_date\":\"2017-04-21\",\"clipwd_pwd\":\"934359\"},{\"clipwd_id\":101779,\"clipwd_idbad\":\"41326882\",\"clipwd_date\":\"2016-02-18\",\"clipwd_pwd\":\"845956\"},{\"clipwd_id\":101363,\"clipwd_idbad\":\"34759199\",\"clipwd_date\":\"2016-10-24\",\"clipwd_pwd\":\"628953\"},{\"clipwd_id\":100364,\"clipwd_idbad\":\"16706998\",\"clipwd_date\":\"2017-09-11\",\"clipwd_pwd\":\"884904\"}]",
            "draw": 1,
            "recordsTotal": 10,
            "recordsFiltered": 10
        },
        "datasrc": "dataTEST",
        "columns": [{
            "data": "clipwd_id",
            "mData": "clipwd_id"
        }, {
            "data": "clipwd_idbad",
            "mData": "clipwd_idbad"
        }, {
            "data": "clipwd_date",
            "mData": "clipwd_date"
        }, {
            "data": "clipwd_pwd",
            "mData": "clipwd_pwd"
        }],
        "aaData": "-- Previously seen object. Not included due to circular reference possibility --",
        "aoColumns": "-- Previously seen object. Not included due to circular reference possibility --"
    }
    
  • HebeldarkHebeldark Posts: 9Questions: 2Answers: 0

    i think about this issue:
    https://datatables.net/manual/data/#Data-source-types

    after reading again this page, i ask:
    when we "feed" the table in local (client side), we must to use array
    when we use ajax with server-side call, we must to use json

    my mistake was to use json to feed my table in local
    no ?

  • HebeldarkHebeldark Posts: 9Questions: 2Answers: 0

    ok

    i convert my json returned by my php server side into a array and datatable accept and show my table

This discussion has been closed.