Header isn't showing which i provide in HTML ?? what could be a reason ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Header isn't showing which i provide in HTML ?? what could be a reason ??

https://code.sololearn.com/Wyr5GLSQJ0bp/?ref=app

27th May 2022, 12:01 PM
Davinder Kumar
Davinder Kumar - avatar
2 Answers
+ 15
It should be like this (I put the DataTable() call in another then()): fetch(url) .then((response) => response.json()) .then((data) => { ... }) .then(() => $('#table').DataTable()); This is needed because "fetch()" is asynchronous. This means that in your code $('#table').DataTable() is executed right after fetch(). So DataTable is built when table is empty. This is why we must execute $('#table').DataTable() in the last then() - to make sure DataTable is built when table is not empty.
28th May 2022, 11:50 AM
Igor Makarsky
Igor Makarsky - avatar
+ 11
What exactly isn't showing for you? I see thead in the markup and it is shown in the final result.
28th May 2022, 10:56 AM
Igor Makarsky
Igor Makarsky - avatar