Do not load data

0

I am populating <table> with ajax, but it does not load anything, nor does it make an error, I tried with an alert the Ajax responses and they are not empty, no parameter is null;

<div id="tb" style="overflow-x: auto;padding-right: 15px;">
    <table id="#tablaPendientes" class="table table-bordered">
        <thead>
            <tr class="thead">
                <th>Cliente</th>
                <th>Monto</th>
                <th>Fecha</th>
                <th>Estado</th>
                <th>Detalles</th>
            </tr>
        </thead>
        <tbody>

        </tbody>
    </table>
    <div id="ttb"></div>
</div>

JS

function nombreFCl(i, ls, c, j) {
    $.ajax({
        url: 'nombreCl',
        type: 'GET',
        data: {id: i},
        success: function (r) {
            var bm = "<button type='button' style='width: 100%' class='btn btn-primary' data-toggle='modal' data-target='#modalDetalle' onclick='detalle(" + ls.factura.idFactura + ")'><i class='fa fa-cogs'></i><label>Detalles</label></button>";
            $("#tablaPendientes").append("<tr><th>" + r.l + "</th><th>" + (ls.factura.montoF - ls.factura.descuentoF) + "</th><th>" + ls.factura.fechaEf + "</th><th>" + ls.factura.estadoF + "</th><th>" + bm + "</th></tr>");

        }
    });
}

Answer

    
asked by user75463 21.04.2018 в 19:48
source

1 answer

2

You are trying to insert a tr into the definition of the table and not into the body of it:

In your HTML:

In the id of the table, delete the pad:

<table id="#tablaPendientes">

for this:

<table id="tablaPendientes">

Change this line of code:

$("#tablaPendientes").append("<tr><th>" + r.l + "</th><th>" + (ls.factura.montoF - ls.factura.descuentoF) + "</th><th>" + ls.factura.fechaEf + "</th><th>" + ls.factura.estadoF + "</th><th>" + bm + "</th></tr>");

For this:

$("#tablaPendientes tbody").append("<tr><th>" + r.l + "</th><th>" + (ls.factura.montoF - ls.factura.descuentoF) + "</th><th>" + ls.factura.fechaEf + "</th><th>" + ls.factura.estadoF + "</th><th>" + bm + "</th></tr>");
    
answered by 21.04.2018 в 20:30