jimfog Posted January 13, 2016 Share Posted January 13, 2016 I am building a web app where the user has the option of storing favorites business users where each one of them offers some services. These services must be seen but the user...whenever he/she clicks on one of the favorites business user. Here is the question: What do you think it is better....prefetch the services with PHP, hide them and make them visible when the user "asks" for them or bring them with ajax the moment the user "asks" them. P.S when I say asks them...I mean a user action such as clicking a button... Link to comment Share on other sites More sharing options...
davej Posted January 13, 2016 Share Posted January 13, 2016 How much data? How likely is the average user to want this data? Link to comment Share on other sites More sharing options...
Ingolme Posted January 14, 2016 Share Posted January 14, 2016 I think the best solution is to have a PHP pagination system which is overridden by AJAX. That means that at no point do you download all the data at once which is a cause of slow page loading. Link to comment Share on other sites More sharing options...
jimfog Posted January 14, 2016 Author Share Posted January 14, 2016 I think the best solution is to have a PHP pagination system which is overridden by AJAX. That means that at no point do you download all the data at once which is a cause of slow page loading. I do not think pagination will be needed here since 2-5 services(for now) must be shown to the user....not much data. So...assuming no pagination, you suggest that I download the data with PHP after all? And hide it of course till the user "asks" them of course... Link to comment Share on other sites More sharing options...
justsomeguy Posted January 14, 2016 Share Posted January 14, 2016 I would ask if there's a compelling reason to load all data at once. Is the user likely to look at all of the data? If not, then why load it all? Link to comment Share on other sites More sharing options...
COBOLdinosaur Posted January 16, 2016 Share Posted January 16, 2016 If the amount of data is small enough that downloading all of it does not cause a noticeable reduction in load time, then I would just download it all. 99.9% of the time AJAX methods are fast enough to result in no serious lag, however the other .1% can result from the user having a poor connect, the load on the server is at a stress level, the user is running something else which can slow down javascript, or the user has a heavy download going on in background. Link to comment Share on other sites More sharing options...
Ingolme Posted January 16, 2016 Share Posted January 16, 2016 If the amount of data is small enough that downloading it all does not cause a noticeable reduction in load time, that probably means it fits on one page of paginated data. If you don't like to see pagination buttons on your page, you can program it not to display the buttons if there's only one page. Link to comment Share on other sites More sharing options...
jimfog Posted January 19, 2016 Author Share Posted January 19, 2016 If the amount of data is small enough that downloading it all does not cause a noticeable reduction in load time, that probably means it fits on one page of paginated data. If you don't like to see pagination buttons on your page, you can program it not to display the buttons if there's only one page. Exactly....the data is small enough so as to justify such a decision-to download all the data. Link to comment Share on other sites More sharing options...
ShadowMage Posted January 20, 2016 Share Posted January 20, 2016 One more thing to consider is AJAX won't work if a user has JavaScript disabled. If you do decide to use AJAX, you need to have a good fallback in place. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now