POST instead of GET with sAjaxSource

POST instead of GET with sAjaxSource

uskerineuskerine Posts: 33Questions: 15Answers: 0

Hi,

I have the following datatables definition:

var oFooTable = $('#fooTable').dataTable({
    "bJQueryUI": false,
    "bAutoWidth": false,
    "sPaginationType": "full_numbers",
    "sDom": '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>',
    "aoColumnDefs": [
        { "bSortable": false, "aTargets": [ 6 ] },
        { "bVisible": false, "aTargets": [ 0 ] }
    ],
    "sAjaxSource": "getFooList?type=SUPERFOO&status=FULLFOO"
});

This generates a GET method against server-side backend.
Is there any way to do exactly the same but with POST method instead of GET while using sAjaxSource?

Thanks,

This question has an accepted answers - jump to answer

Answers

  • xmojmrxmojmr Posts: 18Questions: 2Answers: 3
    edited July 2014

    You can use jQuery to retrieve the ajax data any way you want, preprocess it any way you want and then pass it to the dataTable constructor as aaData (instead of sAjaxSource).

    BTW: switching to new 1.10 API would be a good move, see http://www.datatables.net/upgrade/1.10

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

    In the old 1.9 style you can use sServerMethod to set the HTTP method. In 1.10 use ajax's ajax.type option to set the method (shown in the documentation for ajax).

    Allan

  • uskerineuskerine Posts: 33Questions: 15Answers: 0

    Great! Thanks!

This discussion has been closed.