why the table does not display data that comes from the server?

why the table does not display data that comes from the server?

izumovizumov Posts: 178Questions: 14Answers: 0

My test case is:http://montaj.vianor-konakovo.ru/orders.html?id=16.If you select a row with code 100 in the first column in the first table, the server will return 2 rows for the second table, but they are not displayed and an error occurs. Explain what the problem is. What do I need to change for the program to work correctly?

Replies

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    When I look at the XHR request in the Developer Tools I see the server never sends a response:

    You will need to debug your server script, look for errors, to see why its not returning anything.

    Kevin

  • izumovizumov Posts: 178Questions: 14Answers: 0

    I'm sorry, I forgot to update the server side. Look again. Checked. There is a server-side response

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    You are getting the error Invalid JSON response. The error provides a link with troubleshooting steps: https://datatables.net/manual/tech-notes/1

    Have you followed those steps?

    Kevin

  • izumovizumov Posts: 178Questions: 14Answers: 0

    here is my code to send data

    $json_data = array(
            "draw"            => intval( $params['draw'] ),
            "recordsTotal"    => intval( $totalRecords ),
            "recordsFiltered" => intval($queryRecordsRecords),
            "data"            => $data   // total data array
            );
    
    echo json_encode($json_data); 
    

    I get an answer

    n {"draw":3,"recordsTotal":2,"recordsFiltered":2,"data":[["Cordiant","Polar 2","205\/60 R 15","1","2380.00","2380.00"],["Cordiant","Polar 2","215\/60 R 16","2","3710.00","7420.00"]]}

    I can not understand what the problem is. Tell me please

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    Did you try copying the response into https://jsonlint.com/ as the steps indicate? Looks like the n at the beginning of the JSON string is the problem.

    Kevin

  • izumovizumov Posts: 178Questions: 14Answers: 0

    n I see, but I don’t understand where it comes from and how to remove it

  • izumovizumov Posts: 178Questions: 14Answers: 0

    thank you for your help. With your help, I was able to identify an error in the server code and fix it, and now the code is working

This discussion has been closed.