What is the principle of paging with javascript? How can I interact with php at the backend?
Reply content:
What is the principle of paging with javascript? How can I interact with the backend php?
1. You can send the page number of the current page and the number of records per page as parameters to the backend. the backend then returns the corresponding data, and the front-end displays the corresponding data.
2. Directly query all the data in the database and store the data in global variables. You can only display the corresponding data based on the page number and number of records (this is not recommended)
Not allSelect... from table where... limit (offset, pageNum)
. WhereOffset = pageindex * pageNum
According to your question, it means to useAjax
Asynchronous.
Front end:
AddPage
Parameter,Page
The parameter returns the requested page number to the backend.
Backend:
The backend transmitsPage
You only need to return the specified data to the front-end.
The page number is also requested.
Two parameters are uploaded at the front end.PageSize
(Number of entries per page)SkipCount
(The number of entries skipped, And the frontend is accumulating), and the backend queries accordingly.