Uncaught TypeError: Cannot read property 'length' of undefined

Uncaught TypeError: Cannot read property 'length' of undefined

jupixjupix Posts: 15Questions: 4Answers: 0
edited June 2018 in Free community support

Hi all,

my JSON:

My Code:

<script>
$(document).ready(function() {
    $('#example').DataTable( {
        "ajax": './getCalendarData.php',
        "dataSrc":'',
        "columns": [
            { "data": "id" },
            { "data": "typ_id" },
            { "data": "day" },
            { "data": "users_id" },
            { "data": "text_short" },
            { "data": "text_long" }
    ]
    } );
} );
</script>

The error:

datatables.min.js:89 Uncaught TypeError: Cannot read property 'length' of undefined
    at datatables.min.js:89
    at i (datatables.min.js:76)
    at Object.success (datatables.min.js:76)
    at i (datatables.min.js:14)
    at Object.fireWith [as resolveWith] (datatables.min.js:14)
    at A (datatables.min.js:16)
    at XMLHttpRequest.<anonymous> (datatables.min.js:16)

I realy have no idea. please help.
thanks :smile:

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    ajax.dataSrc should be in the ajax object. See this example.

    Allan

  • jupixjupix Posts: 15Questions: 4Answers: 0

    Thx!!!

    <script> $(document).ready(function() { $('#example').DataTable( { "ajax": { "url": "./getCalendarData.php", "dataSrc": "" }, "columns": [ { "data": "id" }, { "data": "typ_id" }, { "data": "day" }, { "data": "users_id" }, { "data": "text_short" }, { "data": "text_long" } ] } ); } ); </script>

This discussion has been closed.