Recommendation for a Pagination procedure AJAX PHP

2019-03-30 17:38发布

问题:

I am not sure the correct terminology for the process that I am trying to describe. I don't even know which platform is underlying the technique. If you understand my description, please give the link to the site(s) and or the keyword name of the process. I think it is done by AJAX, but I am not certain. I use php as the backend code, I just need to find a way to dynamically display the results. Please give suggestions. I forgot the name of the sites that use this, and my link history expired.

TIA

Description:

The page would have a search form and options. After the user submits, the search is initiated, and the results appear inside the dedicated result area. The page does not refresh, just the info inside the result area.

The display area will show 20 (or whatever) results (lines). There will be next, and previous buttons. If you hit next, the next set of results will display.

I am writing a code that generates 20 results for each display. There is no set number of results, so the results might have a start/first page, but do not have an end page.

Each time the user hits 'next', the program would generate/load new results. It would also store previous results, so that when a user hits 'prev', the previous results can instantly come up.

What techniques/program are theses?

回答1:

Having recently handled pagination with Code Igniter (php framework), the following links might help you and anyone else out:

http://tympanus.net/jPaginate/

http://codeigniter.com/forums/viewthread/93045/

Usability is important and AJAX pagination introduces some important questions that need addressing regarding pagination, the following article will give some usability guidelines for displaying results in a table:

http://thedesignvanguard.com/crud-r-for-read

Code Igniter Prototype Framework Ajax Pagination:

http://codeigniter.com/wiki/AJAX_Pagination_with_CI_Pagination_Library/

Since we're using jQuery, we chose the following, Codeigniter jQuery framework for AJAX pagination

http://tohin.wordpress.com/2008/08/12/codeigniter-ajax-pagination/

http://tohin.wordpress.com/2008/10/07/codeigniter-ajax-pagination-exampleguideline/



回答2:

It is not AJAX for sure.
Nobody uses AJAX for the pagination.

And there are about zillion pagination examples over internet

The only thing is never described in articles is how to persist search options for the other pages.
But it's simple enough: http_build_query() can help you



回答3:

You need to have a GET/POST form submitted via AJAX which contains the fields in the search term and page number.

If you are going to set the page size to 20 results, page_num=4 will show results from 61-80 results.

Usually search results are GET instead of POST (Ex: See Google search results ) along with the page_number as another attribute and value.



回答4:

@IVAN .. good to know that the library came helpful..

About that searching option; check the recent commit in github http://github.com/neotohin/CodeIgniter-Ajax-pagination-Library there is an additional parameter added for searching.

I think the simple code in readme is enough for understanding the mechanism.



回答5:

You could use datatables

https://datatables.net/ https://datatables.net/examples/data_sources/server_side.html

With this plugin using jquery also you could use server sided page request , you just have to handle the plugin post using Ajax. post automatically sends row , page offset column, search criteria you just have to provide the json encode return

and the plugin automatically has library in featuring pagination, search sort number of rows per page and the table formatting.

Needed are jquery, and the plugin css and js for this to work let me know if you understood my explanation.

thanks (=