Uncaught TypeError: Cannot read properties of undefined (reading 'length')
Uncaught TypeError: Cannot read properties of undefined (reading 'length')
NubeProgrammer
Posts: 1Questions: 1Answers: 0
Hi guys,
I am trying to show a doctor's schedule on an HTML page. The data is coming from appointments already made. When printing the variable on the python script, everything is fine I can see the data but on the HTML page I keep on getting an uncaught type error.
Do you see anything wrong with the below?
This is my script:
var table = $(document).ready(function() {
$('#schedule').DataTable({
"ajax": '/api/schedule',
columns: [{
schedule: 'first_name'
},
{
schedule: 'second_name'
},
{
schedule: 'date',
searchable: true
},
{
schedule: 'slot_time',
searchable: true
},
{
schedule: 'Description'
}
],
});
});
This is my HTML:
table id="schedule" class="table table-stripped" style="width:100%">
<thead>
<tr>
<th>First Name</th>
<th>Second Name</th>
<th>Date</th>
<th>Slot Time</th>
<th>Description</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Answers
Looks like what you want to use is
columns.data
. Instead of this:Use:
Depending on your data structure this may or ma not work. The
schedule
would be acolumns
option definition, which Datatables doesn't know about. See the Data and Ajax docs for more information about Datatables supported data structures.Kevin