How to send data from an html table in nodejs?

0

I am trying to send data from a table using jquery to get the values from the table but not send them by POST method in node js, for the moment I only show them in an alert, like the jquery step to an app. post ('/ send_data');.

$("#btnEnviarDatos").click(function () {
$("#datatable-responsive tbody tr").each(function (index) {
    var campo1, campo2, campo3, campo4, campo5, campo6, campo7, campo8, campo9;
    $(this).children("td").each(function (index2) {
        switch (index2) {
            case 1:
            campo1 = $(this).text();
            JsonTabla.fecha = campo1;
            break;
            case 2:
            campo2 = $(this).text();
            JsonTabla.categoria = campo2;
            break;
            case 3:
            campo3 = $(this).text();
            JsonTabla.numfactura = campo3;
            break;
            case 4:
            campo4 = $(this).text();
            JsonTabla.entregado = campo4;
            break;
            case 5:
            campo5 = $(this).text();
            JsonTabla.cargado = campo5;
            break;
            case 6:
            campo6 = $(this).text();
            JsonTabla.empresa = campo6;
            break;
            case 7:
            campo7 = $(this).text();
            JsonTabla.proveedor = campo7;
            break;
            case 8:
            campo8 = $(this).text();
            JsonTabla.valor = campo8;
            break;
            case 9:
            campo9 = $(this).text();
            JsonTabla.retencion = campo9;
            break;
        }
    });
    if(campo1!=undefined && campo2!=undefined && campo3!=undefined && campo4!=undefined && campo5!=undefined && campo6!=undefined && campo7!=undefined && campo8!=undefined && campo9!=undefined){
        alert(''+campo1 + ' - ' + campo2 + ' - ' + campo3+ ' - ' + campo4+ ' - ' + campo5+ ' - ' + campo6+ ' - ' + campo7+ ' - ' + campo8 + ' - ' + campo9);

    }         
});

});

    
asked by Bakke Medina 27.03.2017 в 22:00
source

1 answer

0

What you should do is:

  • Send the content to POST using jQuery.post () link You could do something like
  • From the Node server create an endpoint that receives data from the HTTP POST protocol and processes it. and how it depends on what frameworks and Node libraries you use on the server. For example, using Express is done like this: link
answered by 29.03.2017 / 08:32
source