API ajax.reload() loses page

API ajax.reload() loses page

morissettemorissette Posts: 16Questions: 4Answers: 1

How do I keep on the same page with ajax.reload()?

This question has an accepted answers - jump to answer

Answers

  • morissettemorissette Posts: 16Questions: 4Answers: 1
    mainTable = $("#main_dash").DataTable({
        "language": {
            "url": "../locale/" + locale + "/LC_MESSAGES/" + "dt." + locale + ".txt",
        },
        "pagingType": "full_numbers",
        "pageLength": 10,
        "ajax": {
            "url": "ajax_tables/main_table.php",
            "type": "POST"
        },
        "columnDefs": [
            { "orderable": false, "targets": 0 }
        ],
        "columns": [
            {"data": "flagged"},
            {"data": "date"},
            {"data": "type"},
            {"data": "regarding"},
            {"data": "submitted_by"},
            {"data": "review"},
            {"data": "assign"},
        ],
        "autoWidth":false,
        "order": [[1, 'asc']],
        "deferRender": true,
        "initComplete": function() {
            setInterval(function() {
                mainTable.ajax.reload(null, true);
            }, 5000);
        },
    });
    
  • morissettemorissette Posts: 16Questions: 4Answers: 1

    Okay im stupid. Sorry. true => false in reload params

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    Answer ✓

    Good to hear you got a fix. For anyone else interested, the documentation for this method is here: ajax.reload().

    Allan

  • truelietruelie Posts: 4Questions: 0Answers: 0

    Hi,

    I'm trying this datatable.ajax.reload() function. But I tried several different ways, can't get it working. In the firebug console, I can see the http GET successfully get the data back from the server every 5 secs. However, in the web page, the data table doesn't re-draw. Just showing a msg saying "Processing...". Any idea what I did wrong?

    Thank you very much!
    Joe

  • truelietruelie Posts: 4Questions: 0Answers: 0

    I found the problem. It's on the server side. My bad. I always give a "draw: 1" in the server response. After I remove "draw" parameter, everything is fine.

    Thank you very much for the great data table lib!!

This discussion has been closed.