Should I use PHP or Ajax for dynamically loading content into a social website profile?
Getting开发者_如何学编程 some data from a MySQL database and loading it into the page. None of the stuff really needs to be retrieved at any point other than page load, so that advantage of Ajax is moot. Is there any other advantage to Ajax?
It has the advantage that, if you can defer the retrieval of that data, you can potentially:
- Make the page load faster (since the content sent will be smaller).
- Provide more up-to-date content.
Additionally, if that data may not be retrieved, you can potentially:
- Save bandwidth.
- Lower the server load.
Finally, you need to use Ajax if you want to display content more recent than when the page was loaded without refreshing it.
EDIT
If you insist on loading everything when the page is loaded, the only possible reason I can concoct is when what you loading depends on some logic implemented in Javascript.
精彩评论