How does Ajax paging work?

Asked

Viewed 162 times

4

I’m using a script to make the pagination through Ajax, workable assíncrona, the situation made me curious, because until then I had only used pagination php+mysql, never php+mysql+ajax.

If my bank has 30 registros and I just show 10 per page with Ajax, what happens to others 20? They are loaded?

  • 1

    It depends on how your PHP was encoded. In reality AJAX in the concept is no different than normal, because for each ajax request, Oce goes to the server and this provides a return for you. The Php that Voce calls in the ajax that will do the query, and it will depend on how Voce mounts the query on the server that will define the amount of records that will be searched... Generally as a good one approach we only bring the records of the requested page.

  • 1

    Okay, so let’s imagine that in SELECT with PHP I don’t use LIMIT X, and that there are 200 records in my table. When the page is loaded, will the 200 be searched in the bank? Does AJAX limit this search or does it only display the 10? Because it wouldn’t do any good for me to want to limit the search when the 200 records are uploaded, but they’re not displayed. On second thought, I should make that every page the user navigates to the SELECT query should be executed and fetch 1-10, then 11,21, 22-32 ?

  • 1

    First we need to know when to use the term AJAX. AJAX is simply a request. When Voce uses the phrase "AJAX limits this search" it is actually quite wrong, because it is not AJAX that limits but the PHP function that was called by AJAX.

  • And how do I make the limit given to the query in PHP the same for the request given to AJAX, so that each page is in charge of requesting +10, because otherwise it would cause a damage to traffic, right? Imagine a person who would access the site through mobile data..

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.