klepec Posted March 23, 2012 Share Posted March 23, 2012 Is it smart to use ajax pagination for bulk databases? I have that cool fast jquery live search filter, but i am afraid i wont be able to use it with PHP pagination since (as far as i know) page content is generated (selected from database) every time you go to next page. Any suggestions? Quote Link to comment Share on other sites More sharing options...
scootstah Posted March 23, 2012 Share Posted March 23, 2012 Why does it matter if it's AJAX or a normal request? Quote Link to comment Share on other sites More sharing options...
onlyican Posted March 23, 2012 Share Posted March 23, 2012 A good AJAX script will make a new call to a PHP Script connecting to a DB to get the next page data. If its a LARGE database table (with like 10,000 records) and you pull all of them at once and load into AJAX, you will slow down your website load Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 23, 2012 Share Posted March 23, 2012 A good AJAX script will make a new call to a PHP Script connecting to a DB to get the next page data. If its a LARGE database table (with like 10,000 records) and you pull all of them at once and load into AJAX, you will slow down your website load @onlyican, I think you are implying that the question was about pulling ALL the data down to the client and then using JavaScript to do the pagination. There would be no reason to use AJAX for that since the data could be loaded on first page load. But, yes, if the OP is talking about using pure JavaScript to do the pagination, I agree with you that it would be a foolhardy solution. @op, I assume you were talking abut using AJAX to fetch one page of data at a time as the user selected an option to change the page. There is no intrinsic benefit to doing that. In fact, AJAX just adds another layer of complexity. That's not to say it doesn't have value but, IMO, it is best to first get a process working without AJAX. Once you have it working, then you can add AJAX or other bells and whistles as needed. And, off the top of my head here are some things you may or may want to consider by using AJAX. Cross-browser issues. There are some good JS frameworks that would decrease these problems, but with mobile devices and new browsers it will likely never go away. So, with AJAX you run the risk of some users having problems. As stated above, more complexity. As with a machine, the more moving parts you have the harder it is to maintain and the more likely something will break. A reason TO use AJAX is seamless page transitions. The user doesn't have to refresh the entire web page to see the next 'page' of data. If your process of getting the data takes several seconds this could be useful because no one wants to be looking at a white browser window waiting for a page to load. But, if it's taking a bit to load the page, that's usually a sign that the code is inefficient. Quote Link to comment Share on other sites More sharing options...
klepec Posted March 23, 2012 Author Share Posted March 23, 2012 Yes, I was talking about already generated content ( generating long <li> list of database records - using php and mysql ) which is later sliced to pages using AJAX. The only reason for that ( not using PHP ) is having a whole list of content, so my ajax instant filter could search through all the possible options. I now decided to use different method, which is filter searching through database itself. Someting like ajax autocomplete thingy but outside the input field. Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 23, 2012 Share Posted March 23, 2012 Yes, I was talking about already generated content ( generating long <li> list of database records - using php and mysql ) which is later sliced to pages using AJAX. The only reason for that ( not using PHP ) is having a whole list of content, so my ajax instant filter could search through all the possible options. I now decided to use different method, which is filter searching through database itself. Someting like ajax autocomplete thingy but outside the input field. An auto-complete feature is a nice feature, but is that really what you "need". You need to crawl before you can walk and walk before you run. You're trying to jump to the 100 meter sprint in the Olympics. I would start with a simple paginated grid with the ability to submit search criteria. THEN add additional features to make the data more user friendly. A dynamic lookup can be very problematic if not done correctly. Quote Link to comment Share on other sites More sharing options...
klepec Posted March 23, 2012 Author Share Posted March 23, 2012 Aha okay i understand, What about just PHP submit where you check database for any rows containing "the input" (mysql "LIKE"). And a bit of ajax, just for the live refresh. Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 23, 2012 Share Posted March 23, 2012 Aha okay i understand, What about just PHP submit where you check database for any rows containing "the input" (mysql "LIKE"). Yes And a bit of ajax, just for the live refresh. No. That's not to say you DON'T use AJAX, just start with making it work, THEN add the AJAX if you feel it is worthwhile. Adding AJAX into a process you've never done will only increase the complexity. Quote Link to comment Share on other sites More sharing options...
klepec Posted March 23, 2012 Author Share Posted March 23, 2012 Hehe okay I will do as you advise. Thanks for all the answers. ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.