I am using Datatable’s ServerSide, in which I need to put a modal for the “update” option but it does not execute the function to obtain the data, the data through the serverside if I bring it but the update I do not retrieve.
function consultar(){
$(document).ready(function() {
$('#tableMatPrima').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "serverSideentradas.php",
"lengthMenu": [[15, 30, 45], [15, 30, 45]],
"order": [3, 'desc'],
"searching": true,
"bDestroy": true,
"columnDefs":[
{
"targets": [1, 2, 3, 4],
"className": 'dt-body-center'
},
{
"targets": 4,
"render": function(data, type, row, meta){
const cve_entrada = data;
return '<span class= "btn btn-warning" onclick= "obtenerDatos(cve_entrada)" data-toggle="modal" data-target="#modalMatPrimaUpdate" data-whatever="@getbootstrap"><i class="fas fa-edit"></i> </span>'
}
}
],
"language": {
"lengthMenu": "Mostrar _MENU_ registros por página.",
"zeroRecords": "No se encontró registro.",
"info": " _START_ de _END_ (_TOTAL_ registros totales).",
"infoEmpty": "0 de 0 de 0 registros",
"infoFiltered": "(Encontrado de _MAX_ registros)",
"search": "Buscar: ",
"processing": "Procesando...",
"paginate": {
"first": "Primero",
"previous": "Anterior",
"next": "Siguiente",
"last": "Último"
}
}
} );
} );
}
function obtenerDatos(cve_entrada) {
$.getJSON("modelo_entradas.php?consultar="+cve_entrada, function(registros){
$('#comb_idu').val(registros[0]['cve_entrada']);
$('#comb_mat_primau').val(registros[0]['nombre']);
$('#comb_cantidadu').val(registros[0]['cantidad_entrada']);
});
}