export data to php

export data to php

alzamboalzambo Posts: 38Questions: 17Answers: 1

Hi,
I need to export table filtered data to http://www.tinybutstrong.com php script.
How can I access datatables filtered data?

Thank you,
Alex

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin
    Answer ✓

    What have you tried? The rows().data() method is what I would suggest with a selector-modifier for rows() to get only the filtered rows.

    Allan

  • alzamboalzambo Posts: 38Questions: 17Answers: 1

    Good, thank you so much.

    I managed to access filtered data with rows.data() but which would be the cleanest way to pass that object to ajax call?

    This one:

            // Export
            $('#export').click(function () {
                $.ajax({
                    url     : 'generaFascetta.php',
                    type    : 'post',
                    data    : table.rows({search:'applied'}).data(),
                    dataType: 'json',
                    success : function(returnedData) {
                        console.log(returnedData);
                    }
                });
            });
    

    will produce an error:

    TypeError: 'insertCell' called on an object that does not implement interface HTMLTableRowElement.

    Alex

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin
    Answer ✓

    Try:

    data: table.rows({search:'applied'}).data().toArray()
    

    Otherwise you are passing jQuery a DataTables API instance, which it might not like.

    Allan

This discussion has been closed.