Ajax requests all the data at once, how does the front end realize paging display?

who has the experience to help solve the problem

(need practical information and solve the problem directly, thank you)

(if you come to spray, please leave, thank you)

(not a hand-holding party, but will be paid after the actual operation is solved)

(don"t ask for any reward, you can really solve the problem, naturally)

(want methods, not ideas, thank you)

https://www.rokub.com

pager section:

Ajax:


after looking at your picture, instead of using frameworks such as vue, let's do it for a long time:
first, after ajax requests the data back, save the data with an arr1, then create an empty array arr2, and declare the variable pageindex:1,pagesize:10, and then loop through the array ();

.
var arr1 = ajax.data;
var arr2 = [];
var pageindex = 1;//
var pagesize = 10;//

function pull_page(){
    arr2 = [];
    var key = (--pageindex)*pagesize;
    for(var p_i = key,p_i<pagesize;p_iPP){
        if(arr1[p_i]!=undefined){//p_iarr1p_i<=arr1.length
            arr2.push(arr1[p_i]);
        }
    }
}
pull_page();//pageindex

in other words, it's not scientific to do paging at the front end. You've got all the data, so why do you want to do paging?


tableData, jqgrid can help you


form? Use datatables


  1. No Synchronize request, Synchronize request card page
  2. dataType: json you can get the parse data directly without having to eval yourself

data is all the data. Just do a simulated paging by yourself.
for example:

let data = [];
let filterData = (page)=>{
    let start = page.current*page.size;
    return data.slice( start, start+page.size )    
}

finally assemble the data, and append to the page

Menu