本文介绍了jQuery DataTables:未捕获TypeError:无法读取未定义的属性“mData”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么我收到错误
我尊重DataTables的要求(我也阅读了有关我的错误的另一个主题,我尊重每个答案和解决方案)。请帮助我。
I respect the DataTables requirements (and I also read another topics about my error and I respect every answer and solution). Please help me.
这是我的PHP代码:
<table class="table table-striped table-bordered table-hover" id="sample_1">
<thead>
<tr>
<th class="table-checkbox">
<input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"/>
</th>
<th>
Utilizator
</th>
<th>
Nume complet
</th>
<th>
Clasa
</th>
<th>
Functia
</th>
<th>
E-Mail
</th>
<th>
Ultima logare
</th>
</tr>
</thead>
<tbody>
<?
foreach($data["users"] as $student)
{
?>
<tr class="odd gradeX">
<td>
<input type="checkbox" class="checkboxes" value="1"/>
</td>
<td>
<? echo $student["username"]; ?>
</td>
<td>
<? echo " ".$student["last_name"]." ".$student["first_name"].""; ?>
</td>
<td>
<? echo getclass($student["class"]); ?>
</td>
<td>
<?
$functie = 0;
if($student["role"] == 1)
{
$functie = 1;
echo "Administrator site";
}
if($student["fctsc"])
{
$functie = 1;
echo "Director";
}
if($student["diriginte"])
{
$functie = 1;
echo "Diriginte";
}
if($student["profesor"])
{
$functie = 1;
echo "Profesor";
}
if($functie == 0)
echo "Elev";
?>
</td>
<td>
<a href="mailto:<? echo $student["email"]; ?>">
<? echo $student["email"]; ?>
</a>
</td>
<td class="center">
<? echo $student["lastlogin"]; ?>
</td>
</tr>
<?
}
?>
</tbody>
</table>
推荐答案
检查天气或不是所有php echo的实际输出在所有行上不是NULL的东西,因为DataTables会将任何具有NULL的单元格视为不存在的内容,这也可能导致该错误。
尝试避免将直接php输出到html表。
check weather or not all the php echo's are actually outputting something that is not 'NULL' on all rows as DataTables will treat any cell with just NULL as content as non existant and this can also cause that error.
try avoiding direct php output to html table.
这篇关于jQuery DataTables:未捕获TypeError:无法读取未定义的属性“mData”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!