Ajax: with empty json, "processing" remains turned on

Ajax: with empty json, "processing" remains turned on

Luca4k4Luca4k4 Posts: 9Questions: 3Answers: 0

Hi,
i'm using datatables with ajax and **processing **set to true to show the loading view during the download of the data but.. when i have 0 data, so this json:
[{"data":[]}]

the loading view remains active :(

This is my init:

`var table = $('#table_id').DataTable({
                        "ajax": 'myajaxpage.php',
                        "processing": true,
                        responsive: true,
                        language: {
                           ...
                        },
                        columnDefs: [ .... ],
                    "createdRow": function( row, data, dataIndex ){
                        // other operations ..
                    }
                });

                new $.fn.dataTable.FixedHeader( table );`

myajaxpage.php creates an array (with json_encode($myArr) ) returning [{"data":[]}] with no data and the correct data if something has to be returned.

What am i wrong ? Could you help me please? Thanks!

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    Answer ✓

    [{"data":[]}]

    I think what you return should be: {"data":[]}

    The array you have the returned object in I think is causing the problem.

    Kevin

  • Luca4k4Luca4k4 Posts: 9Questions: 3Answers: 0

    It works greatly! Thank you! :smile:

This discussion has been closed.