TypeError: nTd is undefined
TypeError: nTd is undefined
mldgato
Posts: 13Questions: 3Answers: 0
332/5000
Hello, I have a table whose content changes according to select an option and press a button, the table is generated perfectly but the datatable is not created, the error shown in the console is "TypeError: nTd is undefined", as I see the Error is when I call the function "DataTable", this is the code I am using:
$(document).on('click', '#Consultar', function(e)
{
$('#Reporte').html('<div id="Cargando" class="text-center"><i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i></div>');
var me = $(this);
e.preventDefault();
if(me.data('requestRunning'))
{
return;
}
me.data('requestRunning', true);
var info = "IdCiclo="+$('#IdCiclo').val()+"&EstadoAplicante="+$('#EstadoAplicante').val();
$.ajax(
{
type: "POST",
url: "resultAdmiimprLista.php",
data: info,
success: function(respuesta)
{
$('#Cargando').remove();
$("#IdCiclo").val($("#IdCiclo option:first").val());
$("#EstadoAplicante").val($("#EstadoAplicante option:first").val());
$("#EstadoAplicante").attr('disabled', 'disabled');
$('#ElBoton').html('');
var laasignacion = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var charactersLength = characters.length;
for(var i = 0; i < 10; i++)
{
laasignacion += characters.charAt(Math.floor(Math.random() * charactersLength));
}
$('#Reporte').html('<table id="'+laasignacion+'" class="table table-striped table-bordered table-hover table-condensed dataTable"><thead><tr><th>#</th><th>Apellidos</th><th>Nombres</th><th>Grado</th><th>Estado</th></tr></thead><tbody>'+respuesta+'</tbody><tfoot><tr><th>#</th><th>Apellidos</th><th>Nombres</th><th>Grado</th><th>Estado</th></tr></tfoot></table>');
var t = $('#'+laasignacion).DataTable(
{
"language":
{
"url": "//cdn.datatables.net/plug-ins/1.10.12/i18n/Spanish.json"
}
});
}
});
});
Could you please tell me where is my mistake? Thanks for the support
This discussion has been closed.
Replies
This thread and many others discuss the same question.
Kevin
Resolved. The number of columns was not the same as the headers. Thank you.