How to Pagination With Ajax datatables

How to Pagination With Ajax datatables

bala16bala16 Posts: 5Questions: 4Answers: 0

Only one question, I'm trying to implement an ajax pagination, my result table is the result of mysql query, but the query has LIMIT 0,10 on page 1. When the user click on new pages an ajax call sets the new LIMIT for the same query. what can i do for this. Any Suggestion..

This question has accepted answers - jump to:

Answers

  • Christian SonntagChristian Sonntag Posts: 1Questions: 0Answers: 1
    Answer ✓

    Hi. Maybe this helps: https://datatables.net/examples/data_sources/server_side.html
    In my case i used a php script to provide data from elasticsearch.

  • datatestlorddatatestlord Posts: 6Questions: 3Answers: 1
    Answer ✓

    i am using this below code, but can't get pagination and how to enable scroll here as it's just passing json. please help

    $.ajax({
    "url": 'data/arrays.txt',
    "type": "POST",
    "success": function(json) {
    var tableHeaders;
    $.each(json.columns, function(i, val){
    tableHeaders += "<th>" + val + "</th>";
    });

                    $("#tableDiv").empty();
                    $("#tableDiv").append('<table id="displayTable" class="display" cellspacing="0" width="100%"><thead><tr>' + tableHeaders + '</tr></thead></table>');
                    //$("#tableDiv").find("table thead tr").append(tableHeaders);  
    
                    $('#displayTable').DataTable(json);
                },
                "dataType": "json"
            });
    });
    
  • datatestlorddatatestlord Posts: 6Questions: 3Answers: 1

    It's done

This discussion has been closed.