473,761 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pagination with ajax

hi all,

what i am trying to do is fetching results from mysql through a php
script using ajax and showing them in paginated manner on the browser.
I am getting a json response. Currently i am showing 15 results at a
time. if the user wishes to see next set of results, then a ajax call
is made again which fetches the next 15 results. I want to know what
can be the maximiun number of results in response that is optimal for
browser. I am asking this because the database has about 5000 results.
Should i fetch them all at once and then paginate whole results solely
on browser or 15 at a time is better.

Thanks
neo
Dec 12 '07 #1
4 2117
newbie said the following on 12/12/2007 4:34 AM:
hi all,

what i am trying to do is fetching results from mysql through a php
script using ajax and showing them in paginated manner on the browser.
I am getting a json response. Currently i am showing 15 results at a
time. if the user wishes to see next set of results, then a ajax call
is made again which fetches the next 15 results. I want to know what
can be the maximiun number of results in response that is optimal for
browser. I am asking this because the database has about 5000 results.
Should i fetch them all at once and then paginate whole results solely
on browser or 15 at a time is better.
What is "optimal" for each user is going to be specific to that user.
Retrieving 5000 results on a high end broadband connection is going to
be a lot more "optimal" than it would be on a dial up connection.

Instead of 15 results the first time, get 30. When the user requests
results 16-30, you show them and get 31-45 from the server. When the
user requests 31-45, you show them and get 46-60 from the server and so
on. Then, it is almost instant when they make the request and you can
load the next 15 in the background. It will also keep you from having to
retrieve 5,000 results every time.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 12 '07 #2
On Dec 13, 12:28 am, Randy Webb <HikksNotAtH... @aol.comwrote:
newbie said the following on 12/12/2007 4:34 AM:
hi all,
what i am trying to do is fetching results from mysql through a php
script using ajax and showing them in paginated manner on the browser.
I am getting a json response. Currently i am showing 15 results at a
time. if the user wishes to see next set of results, then a ajax call
is made again which fetches the next 15 results. I want to know what
can be the maximiun number of results in response that is optimal for
browser. I am asking this because the database has about 5000 results.
Should i fetch them all at once and then paginate whole results solely
on browser or 15 at a time is better.

What is "optimal" for each user is going to be specific to that user.
Retrieving 5000 results on a high end broadband connection is going to
be a lot more "optimal" than it would be on a dial up connection.

Instead of 15 results the first time, get 30. When the user requests
results 16-30, you show them and get 31-45 from the server. When the
user requests 31-45, you show them and get 46-60 from the server and so
on. Then, it is almost instant when they make the request and you can
load the next 15 in the background. It will also keep you from having to
retrieve 5,000 results every time.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptT oolbox.com/bestpractices/

hi Randy,

Thanks. That is better i think .
I have one more query. Should i apply the same behavior for previous
button also OR should i cache the results that i have previously
received. In this way no request will be made while previous button is
clicked any time.

--
Thanks
neo
Dec 13 '07 #3
newbie said the following on 12/13/2007 1:00 AM:
On Dec 13, 12:28 am, Randy Webb <HikksNotAtH... @aol.comwrote:
>newbie said the following on 12/12/2007 4:34 AM:
>>hi all,
what i am trying to do is fetching results from mysql through a php
script using ajax and showing them in paginated manner on the browser.
I am getting a json response. Currently i am showing 15 results at a
time. if the user wishes to see next set of results, then a ajax call
is made again which fetches the next 15 results. I want to know what
can be the maximiun number of results in response that is optimal for
browser. I am asking this because the database has about 5000 results.
Should i fetch them all at once and then paginate whole results solely
on browser or 15 at a time is better.
What is "optimal" for each user is going to be specific to that user.
Retrieving 5000 results on a high end broadband connection is going to
be a lot more "optimal" than it would be on a dial up connection.

Instead of 15 results the first time, get 30. When the user requests
results 16-30, you show them and get 31-45 from the server. When the
user requests 31-45, you show them and get 46-60 from the server and so
on. Then, it is almost instant when they make the request and you can
load the next 15 in the background. It will also keep you from having to
retrieve 5,000 results every time.

hi Randy,

Thanks. That is better i think .
I have one more query. Should i apply the same behavior for previous
button also OR should i cache the results that i have previously
received. In this way no request will be made while previous button is
clicked any time.
Sounds like you answered yourself. You have the information, no point in
trashing it and retrieving it again unless 5,000 results is going to
impact the performance of the page.

Don't quote signatures.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 13 '07 #4
On Dec 13, 11:57 am, Randy Webb <HikksNotAtH... @aol.comwrote:
newbie said the following on 12/13/2007 1:00 AM:
On Dec 13, 12:28 am, Randy Webb <HikksNotAtH... @aol.comwrote:
newbie said the following on 12/12/2007 4:34 AM:
>hi all,
what i am trying to do is fetching results from mysql through a php
script using ajax and showing them in paginated manner on the browser.
I am getting a json response. Currently i am showing 15 results at a
time. if the user wishes to see next set of results, then a ajax call
is made again which fetches the next 15 results. I want to know what
can be the maximiun number of results in response that is optimal for
browser. I am asking this because the database has about 5000 results.
Should i fetch them all at once and then paginate whole results solely
on browser or 15 at a time is better.
What is "optimal" for each user is going to be specific to that user.
Retrieving 5000 results on a high end broadband connection is going to
be a lot more "optimal" than it would be on a dial up connection.
Instead of 15 results the first time, get 30. When the user requests
results 16-30, you show them and get 31-45 from the server. When the
user requests 31-45, you show them and get 46-60 from the server and so
on. Then, it is almost instant when they make the request and you can
load the next 15 in the background. It will also keep you from having to
retrieve 5,000 results every time.
hi Randy,
Thanks. That is better i think .
I have one more query. Should i apply the same behavior for previous
button also OR should i cache the results that i have previously
received. In this way no request will be made while previous button is
clicked any time.

Sounds like you answered yourself. You have the information, no point in
trashing it and retrieving it again unless 5,000 results is going to
impact the performance of the page.

Don't quote signatures.


Number of results to be kept at the browser is also a major concern.
How many results can affect the performance of the browser or crash
it.
--
Thanks
neo
Dec 13 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2328
by: Chris H | last post by:
I am having a problem with pagination, basically the problem is happening in the "PREV / NUMBERS / NEXT" links, it appears as if the reason is becasue the increment and decrement operators aren't functioning or the $page variable isnt working in that part of the code... Below is the link to the working but broken page.. as well as the main part of my code... Hopefully someone can explain why the operators arent working or maybe see what i...
11
2782
by: ste | last post by:
Hi there, Further to my recent posts where I've received excellent help from Rik and Jerry, I've ended up with an image gallery on my website that displays images in a table, 3 images per row. This works great and opens all images in the database when I open the url mywebsite/gallery.php, or I can choose certain images (by category) by going to url's like mywebsite/gallery.php?category=landscape Although the above worked perfectly...
1
7410
by: dhanu | last post by:
How to manage pagination in AJAX? My requirement is similar to GMails inbox feature. Whenever a new mail comes in,the newly arrived mail is at the start of my inbox and last row in that page goes to next page(ie Pagination happens automatically without any page refresh). I have used ajaxdisplay tag library from Source Forge which does pagination but doesnot suffice my requirement.ie Whenever a new record is added then it should also be...
1
2155
by: hcvitto | last post by:
hi does anyone know some good and clear tutorial about pagination of php pages and ajax? i'm a newbie of all this stuff.. this is my page (i'm working on pages previously coded only with php, therefore i'm trying to do the transition from php to ajax :) http://office.azero.it/fitoben.it/prodotti/prodotti.php?q=pb thanks Vitto
1
6851
by: shalini jain | last post by:
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code. Below is the code that i have written for pagination but it displays the link of all the pages at one go i.e. if i have 8 pages showing 10 results per page than it shows links for all 8 pages. Previous 1-10 11-20 21-30 31-40 41-50 51-60 61-70 71-80 Next i want to...
16
2778
by: gnawz | last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) { $page = (int)$_GET; } else { $page = 1; } // start fetching from this row number $offset = ($page - 1) * $itemPerPage; return $sql . " LIMIT $offset, $itemPerPage"; } /* Get the links to navigate between...
4
3575
by: ArizonaJohn | last post by:
Hello, The code below works great. The user enters a name into an HTML form, the code looks up a table with that name, and then that table is displayed. I am trying to use pagination with it, and the pagination almost works. The first page of the pagination works fine, but when I click on one of the links for one of the next pages, the page is blank. I have seen people mention this problem, and they have been told that a variable is...
2
2593
by: kkshansid | last post by:
this is my search page on which i am getting two parameters from previous page but the problem is that as soon as i click any other next pages my sql query fails as it doesnt get these two parameters kindly help <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title>
0
9353
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9975
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8794
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7342
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5241
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3481
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2765
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.