mkojoa

Datatables - No Error message in console - But no Rows Displayed

Posted 3 months ago by mkojoa

Javascript to get the data from a server using lumen

    $(document).ready(function () {
        var table = $('#stories').DataTable({
            // "sAjaxSource": ``,
            "paging":   true,
            "ordering": true,
            "info":     true,
            "processing": true,
            "serverSide": true,
            "ajax": {
                url : `http://localhost:8000/stories`,
                "type" : "GET",
                "dataSrc" : "",
                "data" : function(data, callback, settings) {
                    data = [data]//JSON.stringify(data);
                    return data;
                    // console.log(data);
                }
            },
            "columns": [
                { "data": "title" },
                { "data": "content" },
                { "data": "ref_url" },
                { "data": "user_id" },
            ],
            "oLanguage": {
                "sEmptyTable": "Empty Table"
            }
        })
    });

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.