Table remains in "Loading" state when sources from json web service

Table remains in "Loading" state when sources from json web service

ulrikbulrikb Posts: 2Questions: 1Answers: 0

Hi,

I have the simplest possible setup. A table like:

<table id="table_id" class="display"> <thead> <tr> <th>m_Item1</th> <th>m_Item2</th> </tr> </thead> <tbody></tbody> </table>

And a DataTable function like:

$(document).ready(function () {
$('#table_id').DataTable(
{
"ajax": "/Web/Get?count=1000&entity=Account"
}
);
});

The web service is getting called and I can see that it returns json response like:

[{"m_Item1":0,"m_Item2":"Account"},{"m_Item1":1,"m_Item2":"Account"},{"m_Item1":2,"m_Item2":"Account"},{"m_Item1":3,"m_Item2":"Account"},{"m_Item1":4,"m_Item2":"Account"},{"m_Item1":5,"m_Item2":"Account"},{"m_Item1":6,"m_Item2":"Account"},{"m_Item1":7,"m_Item2":"Account"},{"m_Item1":8,"m_Item2":"Account"},
--- truncated ---

Problem is that table remains in "Loading" state forever. Can anyone please point me in right direction?

Thanks
Ulrik

Answers

  • ignignoktignignokt Posts: 146Questions: 4Answers: 39

    You have to define the data if you have an associative object.

    $(document).ready(function(){
        $('#table_id').DataTable({
            columns: [
                {data:"m_Item1"},
                {data:"m_Item2"}
            ],
            ajax: "/Web/Get?count=1000&entity=Account"
        });
    });
    
  • ulrikbulrikb Posts: 2Questions: 1Answers: 0

    Hi, this doesn't seem to fix the problem, my table still remains in 'Loading' forever. My script now looks exactly like you suggested...

This discussion has been closed.