gpt4 book ai didi

php - 未捕获的类型错误 : Datatables

转载 作者:行者123 更新时间:2023-11-28 02:21:37 24 4
gpt4 key购买 nike

我正在尝试使用数据表列出表中的数据,但出现错误

"Uncaught TypeError: Cannot read property 'length' of undefined"

我也不知道为什么。感谢任何帮助,因为我是此类程序的新手。

我的 html:

<table class="table mg-b-0 table-contact" style="width:100% !important;" id="preEnrolTable">
<thead>
<tr>
<!--<th class="wd-5p">
<label class="ckbox mg-b-0">
<input type="checkbox"><span></span>
</label>
</th>-->
<th class="tx-10-force tx-mont tx-medium">DNI</th>
<th class="tx-10-force tx-mont tx-medium hidden-xs-down">Nombre</th>
<th class="tx-10-force tx-mont tx-medium hidden-xs-down">Tarjeta</th>
<th class="tx-10-force tx-mont tx-medium hidden-xs-down">Clave</th>
<th class="tx-10-force tx-mont tx-medium hidden-xs-down">Privilegio</th>
<th class="tx-10-force tx-mont tx-medium hidden-xs-down">Huella</th>
<th class="tx-10-force tx-mont tx-medium hidden-xs-down">Rostro</th>
<th class="wd-5p hidden-xs-down"></th>
</tr>
</thead>
</table>

这是应该带数据的脚本:

function getPreEnrol() {

$("#preEnrolTable").DataTable().clear();
$("#preEnrolTable").DataTable().destroy();
var table = jQuery("#preEnrolTable");
var oTable = table
.on('preXhr.dt',function(e,settins,data){
$("#modalLoadText").html('Estamos cargando la información, espere un momento!');
$("#modalLoad").modal('show');
})

.dataTable({
"processing": false,
"autoWidth": false,
"paging": true,
"pageLength": 5,
"serverSide": true,
"order": [
[0, 'asc']
],
"ajax": {
"url": "SYS_include/WS/PreEnrolamiento/WS_PreEnrolamiento.php",
"data": {
"getDatos":true
}
}
...

这是在 ajax url 中调用的脚本:

$Permisos = new Permisos();
$pagina=45;
$modulo=3;
$i = $Permisos->traerPermisos($json,$pagina,$modulo);

$preEnrol = new PreEnrolamiento();

//error_log($_GET["getDatos"]); // devuelve true
//error_log(print_r($_GET["getDatos"])); // devuelve 1
if(isset($_GET["getDatos"]) && !empty($_GET["getDatos"])){

switch ($i) {
case 1:
case 2:
case 3:
case 4:
case 5:
echo $preEnrol->getPreEnrolamientos($instancia,$sucursal,$conn);
break;
}
}else if(isset($_POST["getNac"]) && !empty($_POST["getNac"])){

switch ($i) {
case 1:
case 2:
case 3:
case 4:
case 5:
$nacionalidades = Dni::obtenerNacionalidades($instancia,$conn);
echo json_encode($nacionalidades);
break;
}

}

最佳答案

最后我找到了我的问题的解决方案,如果有人需要我会在这里发布,我的 ajax 调用:

“ Ajax ”:{

                    "url": "SYS_include/WS/PreEnrolamiento/WS_PreEnrolamiento.php", 
"type":"get", //added
"dataType":'json', //added
"dataSrc": "", //added
"data":{"getDatos": true }
},

关于php - 未捕获的类型错误 : Datatables,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57279433/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com