No data available in table

No data available in table

AriovaldoAriovaldo Posts: 3Questions: 0Answers: 0

Hello everyone.

I have a little difficulty in my first implementation using DataTable, I have already looked at some other forums, but I still have the problem.

I can't display any information in my table, which seems strange, knowing that my ajax request is correct.

I'm programming in ASP.NET C # and using ajax to make a request, my webmethod returns a json object. I did some tests using postman and apparently json is returning correctly.

I appreciate all possible help.

Follows images for better viewing

** Note: my json starts with "d", this is because I am using C # 3.5 or above, which by default serializes all JSON responses in a d variable.

Pictures:

My Ajax:

My WebMethod:

My Html Table:

Request made in postman:

Strong hug.

Replies

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774

    You are not providing the JSON data (result) to Datatables. You will need to use data to do this. Here is an example of using Javascript sourced data:
    https://datatables.net/examples/data_sources/js_array.html

    For example:

        $('#hidden-table-info').DataTable( {
            data: result.d.data,
            columns: [
                { title: "Documento" },
                { title: "ChapaEmissor" },
                { title: "Status" },
            ]
        } );
    

    You misspelled destroy: true.

    The dataSrc option you have is only when you are using the Datatables ajax option. It is ajax.dataSrc. You can remove it since its not a valid option.

    Kevin

  • AriovaldoAriovaldo Posts: 3Questions: 0Answers: 0

    Kevin,

    I don't know how to thank you, thank you very much for your help, problem solved!

This discussion has been closed.