Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

ajax reload is not sending updated params

$
0
0

Hello,

i'm trying to update data in the table based on the selected option in a html select field but it's not working properly. Lets see i have the folowing:

<script type="text/javascript" language="javascript" class="init">

(function($){

$(document).ready(function() {  

    var warehouseID = document.getElementById("selectWarehouse").value;

    var table = $('#XNR').DataTable( {
        dom: 'Tlf<"clear">rtip',
        //serverSide: true,
        ajax: {
            url: "php/getInventories.php",
            type: "POST",
            data: {ware: warehouseID , uid: '<?php echo $uid; ?>' }
        },
        columns: [
            { data: "ProdPhoto" },
            { data: "ProdName" },
            { data: "Inventory" },
            { data: "PriceIn" }
        ],
        pagingType: "full_numbers",
        lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
        order: [ 3, 'asc'],
                
        tableTools: {
        sRowSelect: "os",
        sSwfPath: "libraries/DataTables/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
        aButtons: [         
                {
                    sExtends: 'collection',
                    sButtonText: 'Export',
                    aButtons: [
                        'copy',
                        {
                                sExtends: "pdf",
                                mColumns: "visible",
                                sPdfOrientation: "landscape"
                            },
                            {
                                sExtends: "xls",
                                mColumns: "visible"
                            },
                        'print'
                    ]
                }                   
            ]
        }
    } );
    
    $('#selectWarehouse').change(function() {
        warehouseIDReload = document.getElementById("selectWarehouse").value;
        //table.ajax.reload();
        table.ajax.url('php/getInventories.php?ware='+warehouseIDReload+'&uid="<?php echo $uid; ?>"').load();
    } );
    
} );

}(jQuery));
</script>

The idea here is to reload the data on the table based on user selection on the dropdown, when i change the option on dropdown i can see in firebug that:

getInventories.php?ware=wrh_web_SCkUDn**UcJumUYsQABg

was sent but when i check the post parameters i see:

getInventories.php?ware=all (which is the first value sent on load)

so even if i use the table.ajax.url with new parameters they seem to be wiped out and initial params used when the load() option is called. Does anyone have an explanation for this and how to deal with it so i can update my data completly when a dropdown is changed?


Viewing all articles
Browse latest Browse all 2364

Trending Articles