binding data table on button click even

binding data table on button click even

nallagndanallagnda Posts: 8Questions: 1Answers: 0

Hi i am calling this functions in button click event to bind data from ajax source

function fnLoadTable()
{
var oTable = jQuery("#tblSurveysBreakDown").dataTable({
"aLengthMenu":[10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
"aoColumns": [{ "bSortable": false, "sName": "ClientSurveyId" }],
"iDisplayLength": 10,
"bPaginate": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"bAutoWidth": false,
"bServerSide": true,
"bDestroy": true,
"bFilter": false,
"oLanguage":{ "sLengthMenu": "MENU records per page",
"oPaginate": { "sPrevious": "Prev", "sNext": "Next" } },
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>", "bStateSave": false,
"sAjaxSource": "@Url.Action("AjaxNewSurveysList", "Reports")",
"fnServerParams": function (aoData)
{
aoData.push($('#stage2').serialize());
},
"fnServerData": function (sSource, aoData, fnCallback)
{
$.ajax({ "dataType": 'json', "contentType": "application/json; charset=utf-8",
//type: 'POST',
"url": sSource,
"data": aoData,
"dataSrc": "",
"success": function (msg) {
if (msg.aaData != "")
{

                         $("#DivReport").css("display", "block");
                         var json = jQuery.parseJSON(JSON.stringify(msg.aaData));
                         alert(json);
                         fnCallback(json); $("#tblSurveysBreakDown").show();
                     } else {
                         //ExternalSessionExpiry();
                     }
                 }
             });
            }
        });
        jQuery('#tblSurveysBreakDown .dataTables_length select').addClass("m-wrap small");
    // modify table per page dropdown
    }

and my button click event is

$("#btnGenerateReport").click(function () {
debugger;
fnLoadTable();
});

my table structure is

ClientSurveyId
ClientSurveyId

I am getting the fallowing error "Uncaught TypeError: Cannot read property 'length' of undefined" can you plz help me

This discussion has been closed.