Server side processing is fetching data multiple times on page load...

Server side processing is fetching data multiple times on page load...

jolyon2000jolyon2000 Posts: 12Questions: 0Answers: 0
edited March 2014 in General
When my page load, datatables will send 3 identical requests to the server for the data - any ideas why it might be doing this?

$.ajax({
type: "POST",
url: "/my_data_url/",
data: {a: "get_ajax_data", col_only: "Y"},
dataType: "json",
success: function(data){

// Simply gets the column titles
var scrollx = 0;
var scrollxinner = 0;
var coldata = [];
coldata.push({
"bSortable": true,
"sTitle": "Trainee",
"aTargets": [0]
});
coldata.push({
"bSortable": true,
"sTitle": "Group",
"sWidth": default_col_width+"px",
"aTargets": [1]
});
var titles = data['titles'];
for (var i=0; i < titles.length; i++ ) {

scrollx += default_col_width;
coldata.push({
"bSortable": true,
"sWidth": default_col_width+"px",
"sTitle": titles[i]['name'],
"aTargets": [(i+2)]
});
};

if(titles.length <=5 ){
var scrollx = 1004;
}
scrollxinner = scrollx;

// Now get the table data - THIS PART IS SUBMITTING 3 TIMES!
oTable = $('#joetable').dataTable( {
sDom: '<"top"p<"clear">>rtS<"bottom"p<"clear">>',
"sAjaxSource": "/my_data_url/?a=get_ajax_data",
"bServerSide": true,
"sScrollY": 300,
"sScrollX": "100%",
"bAutoWidth": false,
"bScrollCollapse": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 500,
"sHeightMatch": "semiauto",
"aLengthMenu": [[500, 1000], [500, 1000]],
"aoColumnDefs": coldata
});

new FixedColumns( oTable, {
"iLeftColumns": 2,
"iLeftWidth": 300
});
}
});
This discussion has been closed.