Data is undefined

Data is undefined

Miko55Miko55 Posts: 2Questions: 2Answers: 0

I get this json back from my controller:

[
{"username":"test3","points":62,"sportName":"Basketball"},
{"username":"test2","points":55,"sportName":"Football"},
{"username":"Test1","points":32,"sportName":"Basketball"},
{"username":"miko55","points":25,"sportName":"Football"},
]

And this is my code:

        var table=$('#users-table').DataTable({
            processing: true,
            serverSide: true,
            "ajax": {
                type: "GET",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                url: '{!! route('get.leaderboardsData') !!}',
            },
            columns: [
                { data: 'sportName', name: 'sportName' },
                { data: 'username', name: 'user_id' },
                { data: 'points', name: 'points' },
            ]
        });

I think problem is that current json response doesn't have date around an array, if I am right, how can I fix that. I am using laravel

Answers

This discussion has been closed.