loading ajax source twice?

loading ajax source twice?

bill.martinobill.martino Posts: 38Questions: 0Answers: 0
edited February 2011 in General
For some reason data tables is loading my ajax source twice for each page call. I have gone through and eliminated any other function calls on page load, but cannot stop the ajax source from loading twice, so have deduced that data tables must be doing it. Here is my initialization code, anyone have any ideas?

[code]
// data table
var oTable = $('#resultTable').dataTable({
"fnServerData": function ( sSource, aoData, fnCallback ) {
// get filter ID
var filter_id = $('#storedFilter_id').val();

// send filter ID
aoData.push(
{ "name": "filter_id", "value": $.trim(filter_id) }
);

$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} );
},
"sAjaxSource": "ajax_urls.cfm",
"aLengthMenu": [100,200,500],
"iDisplayLength": 200,
"sPaginationType": "full_numbers",
"sScrollY": 400,
"sScrollX": "100%",
"bProcessing": true,
"bStateSave": false,
"bServerSide": true,
"bSortClasses": false,
"sDom": 'R<"top"il<"showHide">><"pMid"p>rt<"clear">' ,
"oColReorder": {
"iFixedColumns": 1
}

});
[/code]

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    If you add an alert() into the fnServerData function - is it being called twice? There is nothing obvious in the above code that I can see. You could try removing ColReorder from sDom and see if that might be doing it.

    Allan
  • bill.martinobill.martino Posts: 38Questions: 0Answers: 0
    I added an alert around line 3230 and it did pop twice, tried removing the suggested parameters and it didn't make a difference.

    [code]
    oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aoData,
    function(json) {

    alert('go');

    _fnAjaxUpdateDraw( oSettings, json );
    } );
    [/code]
  • bill.martinobill.martino Posts: 38Questions: 0Answers: 0
    I am still having this problem, is anyone else experiencing a similar issue?
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    When I try your code it seems to be sending just a single request as would be expected. Could you post a link to your example please?

    Allan
  • rmorrison100rmorrison100 Posts: 1Questions: 0Answers: 0
    edited March 2011
    I will try if I can identify the problem here.
  • bill.martinobill.martino Posts: 38Questions: 0Answers: 0
    Unfortunately, the code is not publicly accessible...

    Quite an odd problem, eh?

    I removed the column reordering altogether as it wasn't working well for my purposes, and that did not make a difference.
  • bill.martinobill.martino Posts: 38Questions: 0Answers: 0
    Interesting - I have upgraded data tables and fixed columns and now my ajax source loads THREE times. If I remove the fixed columns code, it loads once as it should.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    FixedColumns will do a redraw when it is finished manipulating the table - so since you are using server-side processing, that is expected. You could consider using the pipelining example code to reduce the number of calls made to the server. Interesting that it makes three calls now though - I would have expected two...

    Allan
  • bill.martinobill.martino Posts: 38Questions: 0Answers: 0
    Makes sense... it is becoming kind of comical because now it is loading it 5 times...
  • bill.martinobill.martino Posts: 38Questions: 0Answers: 0
    fyi - upgrading to 1.8 resolved this issue
This discussion has been closed.