How to load part of a page
Moderator: General Moderators
How to load part of a page
I'm creating a test site using PHP in which I load the navbar,banner and news bar using the 'include' command. All three pages I have so far have these includes in them so everything is loaded every time which seems stupid. When I click on a link in the navbar I want to load the new page only (page1.php page2.php etc). How do I accomplish this?
Re: How to load part of a page
You can use AJAX to retrieve only part of a page from the server, then place it somewhere in the page. You can also use an iframe. Both of these possibilities don't update the URL, so I wouldn't recommend using either one of them.
It may seem redundant to keep loading all the parts of the page each page load - but it's necessary. You don't know that any given request isn't the first request, so you need to make each page have all the parts necessary. Building the page each time is a pretty standard practice.
It may seem redundant to keep loading all the parts of the page each page load - but it's necessary. You don't know that any given request isn't the first request, so you need to make each page have all the parts necessary. Building the page each time is a pretty standard practice.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.