Empty table everytime that i search?
Empty table everytime that i search?

Hello,
I'm trying to fill my dataTable with ajax, but since i added that feature using js, pagination stopped working (it shows all the registers at the same page), also, it adds a row at the beggining of the table saying the table is empty everytime that i search for a register, or change the number of registers per page. The first set of registers remains with no change.
Can you guys help me with that issue please?
Thanks everyone!
This question has an accepted answers - jump to answer
Answers
My code is:
The
ajax
docs state this about using thesuccess
function:Are you receiving JSON data? If so why are you building the HTMl table in the success function? Datatables can handle building the table with the JSON data. Plus Datatables does not know about any of the data when adding it this way. This is why searching, etc is not working.
Take a look at this Ajax doc to learn how to use Datatables Ajax. Post any questions.
Kevin
Hello Kevin.
Thank you very much for your answer.
I changed my code to
However, i'm getting the following error: "DataTables warning: table id=dom - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4"
I went to the link but i don't really know how to fix it.
However, the amount of empty rows it is showing matches the amount of registers. And the pagination and everything started working again.
I solved the problem by now, thank u!