+ 2
Header isn't showing which i provide in HTML ?? what could be a reason ??
2 Antworten
+ 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.
+ 11
What exactly isn't showing for you?
I see thead in the markup and it is shown in the final result.