cannot read property length of undefined with ajax and datatables 1.10

cannot read property length of undefined with ajax and datatables 1.10

ArunRahulArunRahul Posts: 16Questions: 4Answers: 0
edited November 2014 in Free community support

I am having the following table structure

userTable = $("#users").DataTable({
        paging : true,                 // activates pagination
        info : true,
        lengthChange : true,
        searching : true,
        serverSide : true,
        ajax : "/Myapp/app/userManipulation/getUsers",
        "columns": [
                    { data: "username" },
                    { data: "password" },
                    { data: "role" },
                    { data: "status" },
                ],
        "language": {
              "emptyTable": "Nothing found yet"
         }
    });

The ajax call returns a list a json response which is a list of objects. I am using spring mvc which returns List<MyObject>.

I am getting "Cannot read property 'length' of undefined"

Answers

  • ArunRahulArunRahul Posts: 16Questions: 4Answers: 0

    I got the answer.. as I am returning the plain list in JSON I should mention dataSrc : "" for the datatables to render it.

This discussion has been closed.