Send datatable data via ajax post to be inserted in database

Send datatable data via ajax post to be inserted in database

jcarvalhojcarvalho Posts: 13Questions: 3Answers: 0
edited December 2020 in Free community support

Hi! Is there an easy way to send the data via ajax post to be inserted in database?

    $("#btnFinalizarRececao").click(function(event)
    {
        let dados = dtLinhaEncomenda.rows().data();
        let ajax = $.ajax({
            url: 'finalizarRececao',
            type: 'POST',
            dataType: 'json',
            data:
            {
                lines: dados,
            },
        })
        .done(function( data )
        {
            console.log("success");
        });        
    });

I just want the values of the rows and columns.
With this code I got an error Uncaught TypeError: 'insertCell' called on an object that does not implement interface HTMLTableRowElement.
jQuery 14

Many thanks!
Jorge

Edited by Kevin:  Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

This question has an accepted answers - jump to answer

Answers

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

    You might need to chain the toArray() API to result in a Javascript Array instead of an API instance. For example:

    let dados = dtLinhaEncomenda.rows().data().toArray();
    

    Kevin

This discussion has been closed.