Datatable Javascript stops working around 250 entries
Datatable Javascript stops working around 250 entries
I'm using datatables to list PubMed articles from within the previous X months. Here's a screenshot: https://ibin.co/2h1Rxk7UueTo.png As you can see, everything works for up to 202 entries; the javascript displays the download buttons, the search box, the show X entries and the pagination.
However, when I search for PubMed articles from the previous 7 months (255 entries), the javascripts stops working. No search box, no show X entries, no pagination, etc. Instead, the datatable displays all 255 entries on a single page. Here's a screenshot: https://ibin.co/2h1U243n8aLG.png
Did anyone else have this error?
This question has an accepted answers - jump to answer
Answers
Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.
Information on how to create a test page, if you can't provide a link to your own page can be found here.
Thanks,
Allan
Hi Allan, thanks for getting back to me.
Here's a link to my page: https://pubmed-search-v3-ssm87-1.c9users.io/.
Here's a link to the files: https://preview.c9users.io/ssm87/pubmed_search_v3/.
Thanks,
ssm87
Can you tell me what I need to search for in order to trigger the error please. The default search returns 37 rows and that appears to work.
Allan
If you search for keyword 'ataxia' and months '7' then you get the error. It should return 260 entries but the javascript for datatable no longer works.
There is a Javascript error showing on the console:
Looking at the response HTML in Chrome's network tools I can see that the final few lines returned from the server are:
Note on lines 7 and 8 how there is an empty
tr
element. That is the issue - DataTables can't find any data in that row, and therefore it throws an error.In order to address this error you need to remove that empty row from the returned HTML. I'm not sure why the server would be putting an entering an empty row into the HTML - perhaps empty data from the database, or an incorrect for in loop.
Allan
Thanks Allen! There was an error in my for loop.