datatables - Server side processing - IE issue )- data not refreshing

datatables - Server side processing - IE issue )- data not refreshing

kyennetikyenneti Posts: 8Questions: 0Answers: 0
edited June 2009 in Bug reports
Alan,
I am facing the following issue on IE7 - Lets say initially I have 8 entries on the table - I used datatables server side processing to get the results. It shows all the 8 records properly. Now I added 1 more record to my database table - Now when I look at my records display, it still showing as 8 records, even though now I have 9 records. Even after refreshing multiple times, datatables is still showing 8 records. Its showing 9 records only upon clearing cache(files and cookies).
In firefox I didn't have this this issue - its always showing current results. ( I checked with 1.5.9, 1.5.8 )

Replies

  • kyennetikyenneti Posts: 8Questions: 0Answers: 0
    edited June 2009
    Alan,
    Here is the code I am using for the server processing -
    [code]$(document).ready(function()
    {
    $('#example').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "recs_server_processing.php"

    } );
    });

    [/code]
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Hi kyenneti,

    It sounds rather like IE is caching the Ajax GET result (which it really shouldn't do - but I think it's a fairly common issue). What I'd recommend doing it using the code from my POST example and seeing if your problem goes away with that: http://datatables.net/1.5-beta/examples/server_side/post.html

    IE doesn't cache POST requests, only GET - show this should do the trick for you. If I am right, I would imagine sorting etc does work in IE?

    Regards,
    Allan
  • kyennetikyenneti Posts: 8Questions: 0Answers: 0
    AS always your solution fixed my IE cache issue-
    Kalyan
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Hi kyenneti,

    Super stuff. Thanks for letting us know :-)

    Allan
  • wenyiwuwenyiwu Posts: 9Questions: 0Answers: 0
    As an alternative, what about setting cache=false in ajaxsetup?
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    DataTables does do this now: https://github.com/DataTables/DataTables/blob/master/media/src/model/model.defaults.js#L884 . It has done for a few years as well - this thread is from 2009 :-)

    Allan
  • bhupendraramanibhupendraramani Posts: 4Questions: 0Answers: 0
    edited August 2012
    Hi Allan,
    I think I have same problem in IE 9.0 ,Its working fine in all other browser. but this link that you have given http://datatables.net/1.5-beta/examples/server_side/post.html is not working.

    Thanks in Advance

    Regards ,
    Bhupendra Ramani


    I am using the following code

    tTable = $("#ticketsTable").dataTable({
    bProcessing: true,
    bServerSide: true,
    sAjaxSource: a,
    fnServerData: fnDataTablesPipeline,
    fnDrawCallback: afterTableDraw,
    fnInitComplete: drawBorders,
    // sScrollYInner:"20%",
    // aaSorting: [[4, "asc"]],
    // bPaginate : false,
    // aoColumns: [null, null, null, null, null, { bSortable: false}] ,
    // sPaginationType: "full_numbers",
    "sScrollY": "200",
    "bScrollCollapse": true,
    "iDisplayStart": displayStart,
    "iDisplayLength": lastIndex,
    "bScrollInfinite": true,
    "bScrollCollapse": true,
    "sScrollY": "100px",
    "iScrollLoadGap": 10,
    bJQueryUI: true,
    oLanguage: { sProcessing: "", sZeroRecords: "SeatKarma found no tickets for this event.", sSearch: "", oPaginate: { sNext: ">", sPrevious: "<"} }
    });


    /*get table datra */
    function fnDataTablesPipeline(sSource, aoData, fnCallback) {

    var sTableId = this.sTableId;
    var iPipe = 5; /* Ajust the pipe size */

    var bNeedServer = false;
    var sEcho = fnGetKey(aoData, "sEcho");
    var iRequestStart = fnGetKey(aoData, "iDisplayStart");
    var iRequestLength = fnGetKey(aoData, "iDisplayLength");
    var iRequestEnd = iRequestStart + iRequestLength;
    oCache.iDisplayStart = iRequestStart;

    /* outside pipeline? */
    if (oCache[sTableId].iCacheLower < 0 || iRequestStart < oCache[sTableId].iCacheLower || iRequestEnd > oCache[sTableId].iCacheUpper || isUpdateCall) {
    bNeedServer = true;
    }

    if (pushdata != 'undefined' && pushdata != '') {

    for (i = 0; i < pushdata.length; i++) {
    aoData.push(pushdata[i]);
    }

    }

    /* sorting etc changed? */
    if (oCache[sTableId].lastRequest && !bNeedServer) {
    for (var i = 0, iLen = aoData.length; i < iLen; i++) {
    if (aoData[i].name != "iDisplayStart" && aoData[i].name != "iDisplayLength" && aoData[i].name != "sEcho") {
    if (aoData[i].value != oCache[sTableId].lastRequest[i].value) {
    bNeedServer = true;
    break;
    }
    }
    }
    }

    /* Store the request for checking next time around */
    oCache[sTableId].lastRequest = aoData.slice();

    if (bNeedServer) {
    if (iRequestStart < oCache[sTableId].iCacheLower) {
    iRequestStart = iRequestStart - (iRequestLength * (iPipe - 1));
    if (iRequestStart < 0) {
    iRequestStart = 0;
    }
    }

    oCache[sTableId].iCacheLower = iRequestStart;
    oCache[sTableId].iCacheUpper = iRequestStart + (iRequestLength * iPipe);
    oCache[sTableId].iDisplayLength = fnGetKey(aoData, "iDisplayLength");
    fnSetKey(aoData, "iDisplayStart", iRequestStart);
    fnSetKey(aoData, "iDisplayLength", iRequestLength * iPipe);

    $.getJSON(sSource, aoData, function (json) {
    /* Callback processing */
    oCache[sTableId].lastJson = jQuery.extend(true, {}, json);

    if (oCache[sTableId].iCacheLower != oCache[sTableId].iDisplayStart) {
    json.aaData.splice(0, oCache[sTableId].iDisplayStart - oCache[sTableId].iCacheLower);
    }
    json.aaData.splice(oCache[sTableId].iDisplayLength, json.aaData.length);

    fnCallback(json)
    });
    }
    else {
    json = jQuery.extend(true, {}, oCache[sTableId].lastJson);
    json.sEcho = sEcho; /* Update the echo for each response */
    json.aaData.splice(0, iRequestStart - oCache[sTableId].iCacheLower);
    json.aaData.splice(iRequestLength, json.aaData.length);
    fnCallback(json);
    return;
    }
    }
This discussion has been closed.