How to send current page number in Ajax request

前端 未结 2 899
遇见更好的自我
遇见更好的自我 2021-01-11 17:27

I am using jQuery DataTable to display huge amount of data in a table. I am getting data page wise on Ajax request like this:

var pageNo = 1;
$(\'#propertyTa         


        
2条回答
  •  甜味超标
    2021-01-11 17:47

    DataTables already sends parameters start and length in the request that you can use to calculate page number, see Server-side processing.

    If you still need to have the URL structure with the page number, you can use the code below:

    "ajax": {
       "data": function(){
          var info = $('#propertyTable').DataTable().page.info();
    
          $('#propertyTable').DataTable().ajax.url(
              "${contextPath}/admin/getNextPageData/"+(info.page + 1)+"/"+10
          );
       }
    },
    

提交回复
热议问题