mkojoa
116
7
General

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

Posted 1 month 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.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.