DataTables警告:请求来自数据源的未知参数“4”

时间:2021-05-17 14:29:21

Are Days and days that I'm looking for this problem, but nothing resolved it! This warning appear after the add of a Student to my Database. The persist of the Data is Ok, so i need to hide this error or adjust it. So i have a Datables that give me this error:

我一直在寻找这个问题,但是没有解决它!在我的数据库中添加了一个学生之后,这个警告就出现了。数据的持久化是可以的,所以我需要隐藏这个错误或者调整它。我有一个数据库给我这个错误

DataTables警告:请求来自数据源的未知参数“4”

This is my html code:

这是我的html代码:

<script type="text/javascript">
    $(document).ready(function () {

        $("#companies").dataTable({
            "bServerSide": true,
            "sAjaxSource": "/studentiSource",
            "bProcessing": true,
            "sPaginationType": "full_numbers",
            "bJQueryUI": true,
            "aoColumns": [
                          {  "sName": "ID", "mDataProp": null,
                             "bSearchable": false,
                             "bSortable": false,
                             "bVisible": false
                                 },
                  { "sName": "NOME",},
                  { "sName": "COGNOME"},
                  { "sName": "USERNAME"},
                  { "sName": "PASSWORD" },
                  { "fnRender": function (oObj) {
                      console.log(oObj);                          
                      return '<a href=${pageContext.request.contextPath}/modificaStudente.jsp?id=' + oObj.aData[0] + '>' + 'Gestisci' + '</a>';
                    }}

                 ]
     }).makeEditable({
         sUpdateURL : "/updateStudenti" ,
         sAddURL: "/studenteServlet",
         sDeleteURL: "/deleteStudenti",
         fnShowError: function (message, action) {
             switch (action) {
                 case "update":
                     jAlert(message, "Update failed");
                     break;
                 case "delete":
                     jAlert(message, "Delete failed");
                     break;
                 case "add":
                     $("#lblAddError").html(message);
                     $("#lblAddError").show();
                     break;
             }
         },
         fnStartProcessingMode: function () {
             $("#processing_message").dialog();
         },
         fnEndProcessingMode: function () {
             $("#processing_message").dialog("close");
         }
      });
                });

And the table is:

表:

 <div id="container">
        <div id="demo_jui">
        <button id="btnAddNewRow" value="Ok">Aggiungi nuovo studente...</button> 
        <button id="btnDeleteRow" value="cancel">Rimuovi utente selezionato</button>
        <div id="processing_message" style="display:none" title="Processing">Attendere.. Caricamento dati in corso</div>
            <table id="companies" class="display">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Nome</th>
                        <th>Cognome</th>
                        <th>Username</th>
                        <th>Password</th>
                        <th>Dispense</th>


                    </tr>
                </thead>
                <tbody >

                </tbody>
            </table>
        </div>


        <form id="formAddNewRow" action="#" title="Aggiungi nuovo studente">
                    <label id="lblAddError" style="display:none" class="error"></label>

            <input type="hidden" id="id" name="id" value="-1" rel="0" />
            <input type="hidden" value="aggiungi" name="action">
            <label for="name">Nome</label><input type="text" name="nome" id="name" class="required" rel="1" />
            <br />
            <label for="name">Cognome</label><input type="text" name="cognome" id="address" rel="2" />
            <br />
            <label for="name">Username</label><input type="text" name="username" id="postcode"/>
            <br />
            <label for="name">Password</label><input type="text" name="password" id="town" rel="3"/>
            <br />

        </form>

    </div>

I'm using Datatables 1.9.4

我使用的datatable 1.9.4

2 个解决方案

#1


2  

I cant give you a definitive answer, since you did not include the JSON response from the server.

我不能给您一个明确的答复,因为您没有包含来自服务器的JSON响应。

This message usally means that DataTables is looking at your data source for array position 4 (which is the fifth element -- the password field) and not finding it.

这个消息通常意味着DataTables正在查看数组位置4的数据源(这是第五个元素——密码字段),并没有找到它。

You should make sure that you are returning a response with all the fields specified in the datatables definition, including the password field.

您应该确保返回的是datatables定义中指定的所有字段的响应,包括密码字段。

#2


0  

The sixth element of your JSON array doesn't contain the value for key '4' because you're fetching a null value, try to parse your JSON array to http://jsoneditoronline.org/ and you'll see it.

JSON数组的第6个元素不包含key '4'的值,因为您正在获取一个空值,试着将JSON数组解析为http://jsoneditoronline.org/,您将看到它。

#1


2  

I cant give you a definitive answer, since you did not include the JSON response from the server.

我不能给您一个明确的答复,因为您没有包含来自服务器的JSON响应。

This message usally means that DataTables is looking at your data source for array position 4 (which is the fifth element -- the password field) and not finding it.

这个消息通常意味着DataTables正在查看数组位置4的数据源(这是第五个元素——密码字段),并没有找到它。

You should make sure that you are returning a response with all the fields specified in the datatables definition, including the password field.

您应该确保返回的是datatables定义中指定的所有字段的响应,包括密码字段。

#2


0  

The sixth element of your JSON array doesn't contain the value for key '4' because you're fetching a null value, try to parse your JSON array to http://jsoneditoronline.org/ and you'll see it.

JSON数组的第6个元素不包含key '4'的值,因为您正在获取一个空值,试着将JSON数组解析为http://jsoneditoronline.org/,您将看到它。