简体   繁体   中英

jquery client side paging on an associative multidimensional array

I'm coding a job portal where I have to bring data from an api. I need to load 1000 of jobs from this site every time. To make the system effective I have loaded 9 jobs for the first time when page loaded and then load the other remaining jobs and these 9 jobs in a java-script array via ajax (jQuery) call.

What I need to do is to apply the paging on the array and maintain the first loaded 9 jobs (since they will be first 9 in the array of 1000 jobs) on the first page. I hope this makes sense.

PS: I'm showing jobs in divs.

Thanks in advance.

Store the jobs data in a jobs array. Then you can always pick the elements to show depending on what the page the user selects.

It would be as simple as

var startIndex = selectedPage * PageSize;
var endIndex = startIndex  + PageSize;

An array of objects should be perfect for the job.

If you want to (pseudo) paginate via JQuery the results in page this could you help:

JSFIDDLE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM