Two tables initialization from a Success funcion of Ajax

Two tables initialization from a Success funcion of Ajax

Mauro26Mauro26 Posts: 17Questions: 7Answers: 0
edited April 2016 in Free community support

Hi there i have a problem with my code and i don't know what i'm doing wrong.

Code:

$('#fileAdd').change(function() {
         debugger;
           var fileAdd =  document.getElementById("fileAdd").files[0].name; 
  
            $.ajax({
                url : 'ajax/getAumento.action',
                data : { "fileAdd" : fileAdd},
                type : 'GET',
                dataType : 'json',
                success : function(json) {
                    makeTableProducto(json);
                    makeTableAumento(json);
                    
                },
                error : function(json) {
                       alert('error');
                }
         });
            
        });

The makeTableProducto function initialize the table and everything it's ok but the makeTableAumento function is never call.
The code of the makeTableProdcuto

function makeTableProducto(data){
         debugger;
         if ( $.fn.dataTable.isDataTable( '#productos' ) ) {
             tprod = $('#productos').DataTable();
             tprod.destroy();
             
             tprod = $('#productos').DataTable( {
                    "aaData": data.itemsProducto,
                    "jQueryUI": true,
                    "dom": '<"search"f><"toolbar">tlp',
                    "buttons": true,
                    aoColumns: [ {"data" : "nombre",
                    "width" : "15%"}, 
                    {"data" : "fechaActualizacion",
                        "width" : "50%" 
                    },
                    {"data" : "costo",
                            "width" : "6%",
                            orderable: false,
                            "render": function ( data, type, row ) {
                                debugger;
                    return  '$' + row.costo.toFixed(2);         
                            }
                        }], 
                           
                });
            
             
            } else {
                tprod = $('#productos').DataTable( {
                    "aaData": data.itemsProducto,
                    "jQueryUI": true,
                    "dom": '<"search"f><"toolbar">tlp',
                    "buttons": true,
                    aoColumns: [ {"data" : "nombre",
                        "width" : "15%"}, 
                       {"data" : "fechaCreacion",
                                "visible": false,
                                orderable: false
                       },
                       {"data" : "fechaActualizacion"},
                       {"data" : "costo",
                                "width" : "6%",
                                orderable: false,
                                "render": function ( data, type, row ) {
                                    debugger;
                        return  '$' + row.costo.toFixed(2);         
                                }
                           }], 
                           
                });
            
                 
                
            }

Anybody knows why the second function is never called?
Regards

Answers

  • allanallan Posts: 61,821Questions: 1Answers: 10,127 Site admin

    Is makeTableProducto throwing an error perhaps? What does your browser's console show?

    Allan

This discussion has been closed.