sAjaxSource in datatable returns error

后端 未结 1 1336
孤独总比滥情好
孤独总比滥情好 2021-01-16 17:53

I keep on receiving this error alert = \"DataTables warning (table id = \'msnc_table\'): Requested unknown parameter \'1\' from the data source for row 0\"

Here\'s a

1条回答
  •  走了就别回头了
    2021-01-16 18:19

    This kind of error from Datatables.net usually means there is a mismatch between the headers / columns you specify and the JSON returned from the server.

    However, in your case there seem to correctly be 10 ths and 10 items in each 'row' of JSON.

    This makes me think that the JSON is incorrectly formatted, or that DataTables can't process some part of it.

    I'd suggest you whip open fiddler and inspect the response as it actually is on client, I don't know much php, so not certain how that echo will actually appear on the client. But certainly think you should encode and set the headers e.g.

    Returning JSON from a PHP Script

    You can copy that fiddler output to http://jsonformatter.curiousconcept.com/ or http://jsonlint.com/ to validate it.

    It may be your dates, with what look like escape characters before the slashes?, are messing it up. N.B. my dates are returned e.g.

    "31/07/2005",
    

    It may be that the line breaks which look to be in wrong place in your JSON are messing it up?

    "2312432\r\n"] 
    

    Suggest you remove them entirely and see if it works, or place the break after the quotes, or after the square bracket closes?

    "2312432"\r\n]
    
    "2312432"]\r\n 
    

    Not sure, but certainly mod the php as per link, and use fiddler to inspect actual response if you're still having problems.

    If you still have issues, then check the answer here.. may help https://stackoverflow.com/a/11475749/661584

    Good Luck ! Worth it to get Datatables.net working - its great !

    0 讨论(0)
提交回复
热议问题