Return a flat array (instead of object) when working with ajax function

Return a flat array (instead of object) when working with ajax function

UdiDUdiD Posts: 16Questions: 7Answers: 1

When working with the ajax option, then using the "dataSrc" option with an empty string makes DataTables treat the data as a plain array. Is it possible to get the same effect when using ajax function (i.e., "ajax": function (data, callback, settings))?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    Yes - what you would do is just wrap your JSON array in an object:

    callback( { data: json } );
    

    if json is just a plain array.

    Allan

This discussion has been closed.