Error: Requested unknown parameter

Error: Requested unknown parameter

thowithowi Posts: 67Questions: 7Answers: 0

Hi all together,

when opening my site, the following error occurs:
DataTables warning: table id=example - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4

You can also verify that by visiting http://stats.valonic.com

Of course I checked the http://datatables.net/tn/4 site. 4 columns in HTML and also 4 columns in SQL response should be fine. Also added columns.defaultContent Option which didn't help.

Do you see any other problems here? What can I do to solve this issue?

Thank you for your help!

My datatable configuration looks the following way:

$(document).ready(function() {
    $('#example').DataTable( {
        "language": {
            "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json",
            "decimal": ",",
            "thousands": ".",
            "lengthMenu": "Zeige _MENU_ Ergebnisse pro Seite",
            "zeroRecords": "Nix gefunden - sorry",
            "info": "Zeige Seite _PAGE_ von _PAGES_",
            "infoEmpty": "Keine Daten vorhanden",
            "infoFiltered": "(gefiltert aus insg. _MAX_ Ergebnissen)"
        },
        "processing": true,
        "serverSide": true,
        "ajax": "server_processing.php"
} );
} );

The JSON should be good and valid I think. I prepare the JSON array the following way, you can see the result here:
http://stats.valonic.com/server_processing.php

$query2 = "select kArtikel, cArtNr, fVKNetto, fUVP from tartikel";
$result = mssql_query($query2);
$a= array();
while ($row = mssql_fetch_assoc($result)) {
    $a['data'][] = $row;
}
echo json_encode($a);

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,083Questions: 26Answers: 4,908
    edited September 2018 Answer ✓

    You are returning an array of objects so you need to use columns.data to define your columns. More info about the data structures here:
    https://datatables.net/manual/data/#Data-source-types

    SSP example with objects:
    https://datatables.net/examples/server_side/object_data.html

    EDIT: Also I noticed your JSON response seems to be returning all the rows and not supplying the paging info the response is required to have for server side processing. Do you really need server side processing enabled?

    If you do then your server script needs to support the request/response requirements described here:
    https://datatables.net/manual/server-side

    Kevin

  • thowithowi Posts: 67Questions: 7Answers: 0

    Hey Kevin,

    thank you for your fast reply!
    yes - columns.data was the problem. But it seems like

    data: data,
    

    it not necessary. If I put it in, no result - if I leave it out, all good. Hm...

    I think for now I don't need server side processing. If I understood it right, server-side processing will fetch the data from the database only for the viewed items, like page 1 or 10 pages. And when I switch to page 2, the next dataset will be fetched.
    This makes sense for very large datasets. Maybe I will change to server-side processing when necessary - and till then, set it to "false".

This discussion has been closed.