简体   繁体   中英

DataTables warning: table id={id} - Invalid JSON response

I know above error is explain here " LINK "

All is working fine in my local-host thats no error popup , nothing in my local-host.

But on my online server i am getting above link error : i am not getting what and where is wrong as when i refresh my page after error then i get data properly .

It works for some time and then again start giving me error and again after refresh of page , error is not seen and my table list all data properly .

I check my all MySQL query on my server its working properly and fine.

   var oTableL1 = $('#table1').dataTable({
        "bProcessing": true, 
        "bServerSide": true,
        "sAjaxSource": "includes/db/list_db.php", 
        "fnServerParams": function ( aoData ) {
            aoData.push( { "name": "more_data", "value": "tablequeryone" } ); 

           // aoData : passing parameter in my list_db.php where
                       i have used if else-if  code for resp. which is working fine
                       in my local-host, also on server after refresh

        }
    }); 

      var oTableL2 = $('#table2').dataTable({
        "bProcessing": true, 
        "bServerSide": true,
        "sAjaxSource": "includes/db/list_db.php", 
        "fnServerParams": function ( aoData ) {
            aoData.push( { "name": "more_data", "value": "tablequerytwo" } );
        }
    }); 

      var oTableL3 = $('#table3').dataTable({
        "bProcessing": true, 
        "bServerSide": true,
        "sAjaxSource": "includes/db/list_db.php", 
        "fnServerParams": function ( aoData ) {
            aoData.push( { "name": "more_data", "value": "tablequerythree } );
        }
    });

ONLINE SERVER : IF I REFRESH MY PAGE then some time it get my data properly but some time its show me error , but after refresh of page it show me data properly without any error .. not getting what wrong.

same thing is happening for search and pagination and records list .

Since you are getting output on random refresh it has to do with the data table initialization and assignment of data. There are multiple scenarios that can lead to above error;

  • If data is being assigned to grid prior to element is registered in DOM
  • Data table is being initialized multiple times when its already available in the DOM
    • Solution; Clear the table and reassign the data.
  • Data mist match (in short grid contains columns; Col1, Col2, Col3 while table array is not of same length)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM