javascript - jQuery Datatables Requested unknown parameter '0' for row '0' column '0&

I have the flat Json string produced by my aspx webpage..[{"UserName":"ABENS"},{&qu

I have the flat Json string produced by my aspx webpage..

[{"UserName":"ABENS"},{"UserName":"AILPAL"},{"UserName":"ANDREW.GUILLERMO"}.....(so on so forth)]

I have declared the following html..

            <table id="tblUserAccountsManagement" class="display" cellspacing="0">                    
                         <thead>
                            <tr>
                                <th>UserName</th>

                            </tr>
                        </thead>                                

                    </table>

I have the following Jquery...

  $(document).ready(function () {

        var tbl = $('#tblUserAccountsManagement').DataTable({

            "ajax": {

                "url": "AccountsManagementJSON.aspx",
                "dataSrc": ""

            },

            "columns": [

                { "data": 'UserName' }

            ],
            autofill: true,
            select: true,
            responsive: true,
            buttons: true,
            length: 10,

        });
    });

Why does it still output the error?

Requested unknown parameter '0' for row '0' column '0'

I've read everything followed every troubleshoot there is, made sure that html and jQuery definition are intact.. why doesn't it still work?

What I don't understand is that I've tried this before here and it worked. I only had to add dataSrc: "" and that did the trick. I followed my previous example to the letter and now it does not work.

What's weird is that it does show the number of rows (39 rows like in the JSON) But it won't show content. Why is that?

I have the flat Json string produced by my aspx webpage..

[{"UserName":"ABENS"},{"UserName":"AILPAL"},{"UserName":"ANDREW.GUILLERMO"}.....(so on so forth)]

I have declared the following html..

            <table id="tblUserAccountsManagement" class="display" cellspacing="0">                    
                         <thead>
                            <tr>
                                <th>UserName</th>

                            </tr>
                        </thead>                                

                    </table>

I have the following Jquery...

  $(document).ready(function () {

        var tbl = $('#tblUserAccountsManagement').DataTable({

            "ajax": {

                "url": "AccountsManagementJSON.aspx",
                "dataSrc": ""

            },

            "columns": [

                { "data": 'UserName' }

            ],
            autofill: true,
            select: true,
            responsive: true,
            buttons: true,
            length: 10,

        });
    });

Why does it still output the error?

Requested unknown parameter '0' for row '0' column '0'

I've read everything followed every troubleshoot there is, made sure that html and jQuery definition are intact.. why doesn't it still work?

What I don't understand is that I've tried this before here and it worked. I only had to add dataSrc: "" and that did the trick. I followed my previous example to the letter and now it does not work.

What's weird is that it does show the number of rows (39 rows like in the JSON) But it won't show content. Why is that?

Share Improve this question edited Jul 26, 2019 at 20:29 Malcolm Salvador asked Feb 28, 2017 at 8:31 Malcolm SalvadorMalcolm Salvador 1,5663 gold badges22 silver badges41 bronze badges 4
  • Can you supply an example of your JSON? May not be formatted right for datatables? – jonmrich Commented Mar 1, 2017 at 1:06
  • The example is included in the question. It is a flat array. I followed the guide here: datatables/examples/ajax/custom_data_flat.html – Malcolm Salvador Commented Mar 1, 2017 at 1:45
  • That's very odd, I've worked up a JSFiddle with your data (jsfiddle/annoyingmouse/da2vbL1L) and everything seems to be working correctly. Just an idea, but your server isn't doing something odd like adding a BOM? Probably not but perhaps look at the response from your ajax and check? – annoyingmouse Commented Mar 1, 2017 at 7:38
  • @annoyingmouse thanks for taking concern sir. Actually I think maybe it's a quirk with asp webforms? I gotta get out of this platform. Wwe've actually resolved it here. datatables/forums/discussion/40914/… – Malcolm Salvador Commented Mar 1, 2017 at 9:24
Add a ment  | 

1 Answer 1

Reset to default 5

I have resolved the problem: I have used aoColumns and mData with this setup (Webforms with MasterPages).

the following now works :

 $(document).ready(function () {

    var tbl = $('#tblUserAccountsManagement').DataTable({

        "ajax": {

            "url": "AccountsManagementJSON.aspx",
            "dataSrc": ""

        },

        aoColumns: [

            { mData: 'UserName' }

        ],
        autofill: true,
        select: true,
        responsive: true,
        buttons: true,
        length: 10,

    });
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743921171a4530084.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信