Datatable not applying ajax data correctly

Datatable not applying ajax data correctly

SodabreadSodabread Posts: 1Questions: 1Answers: 0

I'm currently in the process of updating one of our internal applications to use DataTables 1.10.4 (from a much legacied version). When I make the call to reload the datatable via ajax, it appears that the URL as well as all the data parameters aren't getting set as I expected.

The initial table setup:

$('#linktable').DataTable({
            "bProcessing": true,
            "bJQueryUI": true,
            "bAutoWidth": false,
            "sDom": '<"H"r>t<"F">',
            "oLanguage": { "sZeroRecords": "No Links entered for this Product Form", "sProcessing": "<img src='../../../../Content/images/ajax-loader-bar.gif' />" },
            "aoColumns": [
                        { "sName": "ShortName", "sWidth": "27%", "bSortable": false },
                        { "sName": "Type", "sWidth": "11%", "bSortable": false },
                        { "sName": "LinkPath", "sWidth": "50%", "bSortable": false },
                        { "sName": "Actions", "sWidth": "12%", "bSortable": false }
                    ]
        });

Called in a later function after a row is added/deleted/edited:

function LoadLinkList(planName, effDate, company) {
     var table = $('#linktable').DataTable({
       "processing": true,
       "serverSide": true,
       "ajax": {
            "url": '@Url.Action("LinkList","ProductCatalog")',
                "type": "GET",
            "data": function (d) {
                d.ProductForm = planName;
                d.EffectiveDate = effDate;
                d.CompanyID = company;
           }
       }
     });

     table.ajax.reload(null, false);
}

This section will end up breaking in jquery because the URL is null. If I set the URL outside of the initializer, it works just fine, but I end up having to append the parameters to the URL in order to get it to call the controller method properly. Without appending the parameters, everything is sent to the method as null. I've made sure that planName, effDate and company are all valid variables and have data.

Any help figuring this out is greatly appreciated as I'm fairly lost as to what I'm doing wrong here.

This discussion has been closed.