Portal Home > Knowledgebase > Articles Database > ajax pagination : php / mysql ?


ajax pagination : php / mysql ?




Posted by acctman, 12-26-2008, 10:48 AM
ajax pagination : php / mysql ? does anyone know of a working ajax pagination example that I can look at?

Posted by jaseeey, 01-02-2009, 10:48 PM
Not sure of a working example, but it's not too hard to make. If you know how to make one without AJAX, it'd be just a matter of implementing a number of dynamic DIV's within the script. JQuery would be a nice way to start off as it provides the framework for you to easily load a page within a DIV.

Posted by AnoxiA, 01-03-2009, 07:10 AM
there is alot of examples out there mate, anyway i cannot post a links so here you go: www DOT dynamicdrive DOT com/dynamicindex17/ajaxpaginate/ that is the best one i'v know on the net, really simple and really powerfull. [= hope i helped, Yahav. [EDIT] ohh i just remembered - i know some perfect example but you will need CF for that, anyway check it out: cfsilence DOT com/blog/client/index.cfm/2007/8/21/Ajax-Paging-Through-Records-On-Scroll

Posted by Czaries, 01-05-2009, 12:02 AM
DON'T do AJAX pagination. Major AJAX functions and overuse really tend to irritate me. If you're changing page content with AJAX, there are all kinds of problems that crop up: - Can't use the BACK button without extensive custom JS - Can't link to a specific page because the URL never changes - JS disabled = Can't use your website AJAX should be used for enhancements only. There is nothing wrong with reloading the page to view different content. That's what the URI means... Different content at each different URI. Don't contribute to breaking the web by making the whole thing AJAX. It will cause more issues and work for you than it's worth. __________________phpDataMapper - Object-Oriented PHP5 Data Mapper ORMOnline Javascript Compressor - minify or pack your javascript

Posted by AnoxiA, 01-05-2009, 06:22 AM
Quote: Originally Posted by Czaries - Can't use the BACK button without extensive custom JS - Can't link to a specific page because the URL never changes - JS disabled = Can't use your website every body and his own choices and needs. i'm personally LOVE ajax, and use it more then often.! as for your list of problem: - there is a JS to make your Back button Function with Ajax. -Sure you can Link to specific page!where did you get that one?! ofcorse you can! -the last one you right, but you can develop your site at a way that will show browsers without JS another version of the page. or its just will show them the whole content at one page [= anyway its your choice ajax got many pluses!

Posted by Czaries, 01-13-2009, 01:20 PM
Quote: Originally Posted by AnoxiA every body and his own choices and needs. i'm personally LOVE ajax, and use it more then often.! as for your list of problem: - there is a JS to make your Back button Function with Ajax. -Sure you can Link to specific page!where did you get that one?! ofcorse you can! -the last one you right, but you can develop your site at a way that will show browsers without JS another version of the page. or its just will show them the whole content at one page [= anyway its your choice ajax got many pluses! 1) JS solution for back/prev buttons is extra work, time, and effort, and extra load time for the user 2) If AJAX changes the page content, you CANNOT link to it like you normally would. So if a user is on page 4 of your pagination list, and they copy/paste the URL to someone else, they will be on page 1. The URL does NOT change on AJAX calls, I don't know why you think it does. 3) Again, it's a bunch of extra needless development time and effort. And if you show all the results on one page anyways, it defeats the whole purpose of pagination in the first place. __________________phpDataMapper - Object-Oriented PHP5 Data Mapper ORMOnline Javascript Compressor - minify or pack your javascript

Posted by code_iain, 01-13-2009, 10:16 PM
sample Hi acctman, I wrote you a quick example. I've used ajax pagination many times. It's good for account related things when the url is not going to be shared; tickets, call logs, etc. I'm a new member so I don't have url posting rights, but here is location of the example. codeparachute.com/sandbox/sample.php I can send you a copy of the code for your reference, just email me if you're interested: iain -at- codeparachute.com

Posted by ZackN, 01-13-2009, 10:28 PM
Quote: Originally Posted by Czaries 1) JS solution for back/prev buttons is extra work, time, and effort, and extra load time for the user 2) If AJAX changes the page content, you CANNOT link to it like you normally would. So if a user is on page 4 of your pagination list, and they copy/paste the URL to someone else, they will be on page 1. The URL does NOT change on AJAX calls, I don't know why you think it does. 3) Again, it's a bunch of extra needless development time and effort. And if you show all the results on one page anyways, it defeats the whole purpose of pagination in the first place. While I agree with most of this, there are many valid uses for ajax pagination. As for number 2, you can use URI fragment to create linkable ajax pages. I think this is how Google does it for Gmail? And for number 3, it doesn't always defeat the purpose. It's a good use for something like video comments, where reloading the page would inturrupt the video.

Posted by jstanden, 01-15-2009, 07:18 AM
You could check out: * YUI: Yahoo User Interface Library (http://developer.yahoo.com/yui) -or- * jQuery for Designers (http://jqueryfordesigners.com) YUI has a more complete widget library and jQuery is a bit more elegant. You should be at least be somewhat experienced with pre-Ajax web programming before digging in. __________________Jeff Standen, Chief of R

Posted by jstanden, 01-15-2009, 07:25 AM
Quote: Originally Posted by Czaries 1) JS solution for back/prev buttons is extra work, time, and effort, and extra load time for the user 2) If AJAX changes the page content, you CANNOT link to it like you normally would [...] 3) [...] if you show all the results on one page anyways, it defeats the whole purpose of pagination in the first place. There's no one right answer in development. #1) Or you can persist the currently selected page and allow the back button to navigate _web pages_ opposed to pages of UI elements. That's usually what a novice user expects anyway. #2) Sure you can, you just have to think about your permalinks and how the query arguments are accessible to your UI elements. It's trivial. #3) If you have few enough results to display on a page, then sure, there is no point to a superfluous Ajax effect. If you're like us, and end up with the potential for 200,000 rows, with statistical information in a sidebar you don't want to reload constantly, then Ajax is a very useful and efficient design pattern (when done tastefully, I'll give you that.) -- "To a man with the hammer, the whole world is a nail". That applies to both people using Ajax for everything or hating Ajax for everything. Don't be the guy with a hammer. Use the right tool or pattern for the job. I'm with you on disliking tools/langs/patterns just because they're popular and people abuse them. But you're just as bad as they are if you start talking in absolutes. __________________Jeff Standen, Chief of R



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Moving large site (Views: 500)
Companies honesty ? (Views: 449)