pagination with ajax

Discussion in 'Javascript' started by newbie, Dec 12, 2007.

  1. newbie

    newbie Guest

    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
     
    newbie, Dec 12, 2007
    #1
    1. Advertising

  2. newbie

    newbie Guest

    On Dec 13, 12:28 am, Randy Webb <> wrote:
    > 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.javascript FAQ -http://jibbering.com/faq/index.html
    > Javascript Best Practices -http://www.JavascriptToolbox.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
     
    newbie, Dec 13, 2007
    #2
    1. Advertising

  3. newbie

    newbie Guest

    On Dec 13, 11:57 am, Randy Webb <> wrote:
    > newbie said the following on 12/13/2007 1:00 AM:
    >
    >
    >
    > > On Dec 13, 12:28 am, Randy Webb <> wrote:
    > >> 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
     
    newbie, Dec 13, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joseph D. DeJohn

    DataGrid Pagination

    Joseph D. DeJohn, Jul 4, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    4,394
    Daniel Bass
    Jul 4, 2003
  2. Sreejumon[MVP]

    Re: datagrid custom pagination

    Sreejumon[MVP], Jul 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    432
    Sreejumon[MVP]
    Jul 8, 2003
  3. minnie
    Replies:
    1
    Views:
    721
    Andrew Thompson
    Dec 13, 2006
  4. David Heinemeier Hansson
    Replies:
    7
    Views:
    120
    Glenn Smith
    Mar 24, 2005
  5. Rich Hephner

    Eliminating Pagination with Ajax

    Rich Hephner, Jul 24, 2007, in forum: Javascript
    Replies:
    1
    Views:
    120
    David Mark
    Jul 24, 2007
Loading...

Share This Page