how to send data from datatables editor as json?

how to send data from datatables editor as json?

lekarlrlekarlr Posts: 2Questions: 1Answers: 0

if send data as in example i get:
action=edit
data[first_name]=Airi
data[last_name]=Satou
data[position]=Accountant
data[office]=Tokyo
data[extn]=5407
data[start_date]=2008-11-28
data[salary]=162700
id=row_5

is it possible to send data as json?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Answer ✓

    Yes, what you can do is use the ajax.data option as a function and have it return the data as a JSON string - e.g.:

    var editor = new $.fn.dataTable.Editor( {
      ajax: {
        url: '...',
        data: function ( d ) {
          return JSON.stringify( d );
        }
      },
      ...
    } );
    

    It isn't currently in the documentation that you can do that, however, I've decided to make it a supported feature (for DataTables as well) and it will be in the next documentation update.

    Allan

  • lekarlrlekarlr Posts: 2Questions: 1Answers: 0

    Thank you

This discussion has been closed.