DataTables: Cannot read property 'length' of undefined-- using datatables editor

DataTables: Cannot read property 'length' of undefined-- using datatables editor

mailbirdsa@gmail.commailbirdsa@gmail.com Posts: 4Questions: 3Answers: 0
edited January 2020 in Free community support

Hi,

I'm currently reading the table as follow:

$('#fans').dataTable( {
          dom: 'Bfrtip',

        //   "processing": true,
        //   "serverSide": true,

              "ajax": "/api/fans",

           columns: [
            { data: "id" },
            { data: "firstName" },
            { data: "surname" },

          ])}

-------------JSON data below > definitely not the default Datatables supported json format

{
"success":true,
"fans":[
{
"id":1111,
"firstName":"Joe",
"surname":"Marley",

"MoreDetail":{

"calledName":"bob",
"idType":"singer",

},

"_isDeleted":0
}
}

THANKS!

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583
    Answer ✓

    Change

    "ajax": "/api/fans",
    

    to

    "ajax": {
        url: "/api/fans",
        dataSrc: 'fans'
    }
    

    and that should do the trick,

    Colin

This discussion has been closed.