Uncaught TypeError: Cannot read property 'splice' of undefined

Uncaught TypeError: Cannot read property 'splice' of undefined

malko7malko7 Posts: 2Questions: 1Answers: 0
edited June 2016 in Free community support

Hi, I dont know why I have this error.

I copied the same example from page, and only I changed the initialization of the datable.

Here is my code.

Code(http://jsfiddle.net/yVbYQ/7733/)

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,281Questions: 1Answers: 10,425 Site admin
    Answer ✓

    This is what the JSFiddle echo serivce is returning:

    {
        "data[19][age]": "84",
        "data[7][age]": "97",
        "columns[9][orderable]": "true",
        "data[9][age]": "23",
        "data[4][age]": "92",
        "columns[8][data]": "8",
        "columns[4][search][regex]": "false",
        "columns[4][orderable]": "true",
        "columns[5][orderable]": "true",
        "columns[2][orderable]": "true",
        "data[13][age]": "59",
        "order[0][dir]": "asc",
        "columns[0][search][regex]": "false",
        "columns[6][searchable]": "true",
        "data[10][id]": "10",
        "data[15][id]": "15",
        "columns[4][name]": "",
        "columns[9][data]": "9",
        "data[20][id]": "20",
        "data[0][id]": "0",
        "start": "0",
        "data[18][id]": "18",
        "data[12][age]": "64",
        ...
    }
    

    Which isn't the expected format for server-side processing. You could JSON.stringify that string, it would still be missing the draw and recordsTotal, etc, parameters that are required.

    Allan

  • malko7malko7 Posts: 2Questions: 1Answers: 0

    Thanks for answer, but I have a doubts:

    JSON.stringify or JSON.parse?

    Why return a string and no a json object?

  • allanallan Posts: 63,281Questions: 1Answers: 10,425 Site admin

    Sorry yes - you should JSON.parse the string :-).

    Allan

This discussion has been closed.