Invalid JSON Error but actually valid?

Invalid JSON Error but actually valid?

ghafarizghafariz Posts: 14Questions: 6Answers: 0
edited February 2022 in General

This is the JS:
$(".tabel-penghuni table").DataTable({ "processing": true, "serverSide": true, "ajax": { "url": "data.php", "data": { "key": "tOmQ2OaWiX4DcnXZfK29HyK9QekITCYMfqBpU2Uv" } } });

This is the Servers-side returning data, im using Postman:
{"draw":0,"recordsTotal":5,"recordsFiltered":5,"data":[{"1":"fariz"},{"1":"adnin"},{"1":"haves"},{"1":"alfis"},{"1":"fariz"}]}

i dont know how to fix, im using debugger, no error shown, kinda frustated for now... can you help me?

Answers

  • kthorngrenkthorngren Posts: 21,300Questions: 26Answers: 4,945

    "draw":0

    This is not correct. The draw parameter is a sequence number and should reflect the sequence sent from the client. See the Server side processing docs for more details.

    This is the Servers-side returning data, im using Postman:

    Maybe this is why you are seeing "draw":0. What is the JSON response you see using the browser's network inspector tool? See the steps outlined in the technote linked in the error:
    https://datatables.net/manual/tech-notes/1

    Kevin

  • ghafarizghafariz Posts: 14Questions: 6Answers: 0

    hi kthorngren, thank you for the response, and sorry for late reply.
    its solved but i dont know what ive done, i just trying to type the code from beginning. thanks

Sign In or Register to comment.