Jquery Datatable sending many ajax requests

Jquery Datatable sending many ajax requests

sarveshkushwahasarveshkushwaha Posts: 8Questions: 1Answers: 0

I am using jquery DataTable 1.9 and facing a weird problem.My code is sending many(equal to the column in a table) requests to the server.Below is the code , I am using :
tableContainer.dataTable({

        sDom: '<"row"<"span6"l><"span6">r>t<"row"<"span6"i><"span6"p>>',
        sPaginationType: 'bootstrap',
        bProcessing: true,
        bServerSide: true,
        bStateSave: false,
        bPaginate: true, 
        oLanguage: {
            sLengthMenu: '_MENU_ records per page'
        },
        bFilter: true,
        bSort: false ,
        // Setup for responsive datatables helper.
        bAutoWidth: false,
        fnPreDrawCallback: function ()
        {
            // Initialize the responsive datatables helper once.
            if (!responsiveHelper)
            {
                responsiveHelper = new ResponsiveDatatablesHelper(tableContainer, breakpointDefinition);
            }

        },

        fnRowCallback: function (nRow, aData, iDisplayIndex, iDisplayIndexFull)
        {
            responsiveHelper.createExpandIcon(nRow);
        },

        bDestroy: true,
        sAjaxSource: "Getdata",
        bDeferRender: true,
        aoColumns: [

            @foreach (var item in Model.gridAllColumnName)
            {
                <text> { "sName": "@item" }, </text>
            }

        ]
           ,

        fnServerData: function (sSource, aoData, fnCallback, oSettings) {
            if (oSettings.aaSorting.length)
            {

                aoData.push({ "name":"popUpId" ,"value": "@Model.popUpId" });
            }


                oSettings.jqXHR =  $.ajax({

                    "dataType": 'json',
                    "contentType": "application/json; charset=utf-8",
                    "type": "GET",
                    "url": sSource,
                    "data": aoData,
                    "success":
                                function (msg)
                                {

                                    var json = jQuery.parseJSON(msg);
                                    fnCallback(json);
                                    $('#' + dataTableId ).removeClass('hidden');
                                }
                });

        },
        fnCreatedRow: function( nRow, aData, iDataIndex ) {
            // Bold the grade for all 'A' grade browsers
            $(nRow).attr('onclick', 'getValue("@Model.gridGetValue",this);');
        }

    });

I think my issue is in function FnServerData which is causing ajax requests equal to column in table.Please take a look and help me out.

This discussion has been closed.