Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php conceptual Q?

Status
Not open for further replies.

BobMCT

IS-IT--Management
Sep 11, 2000
756
US
Working on a project with another developer. He has developed a tabular menuing facility and when any tab is clicked it triggers an invocation to another program. The other program (my part) delivers the content. The user can enter/change any data fields and then clicks to save. The result is that the same page is redisplayed. To navigate to a different page the user clicks on another tab. Simple.

Here's my conceptual question: as my part (the content portion) does not output any heading information it simply writes to the data stream picking up where the headers end. While that works for the initial display, is there any way to redisplay without reoutputting the headers? Or, as I surmise, must the headers again be first to start/setup the new page?

I've been doing this for many moons and I just can't get my head around this (yet). Any suggestions/guidance/ideas appreciated.
Thanks [dazed]

 
...is there any way to redisplay without reoutputting the headers?

Not with PHP alone. PHP runs on the server, for that to happen a call to the server must occur, and as such the page must load or reload. Once the page has finished loading PHP is no longer running and cannot be made to run until another server call is made.

Without any supporting tech, the only way to make a call to the server is to refresh the page and as such reload / output headers.


The way to get PHP to be run without having to reload the page, i.e output headers is to use an AJAX call via Javascript. So the PHP script is called by the JS code without having to reload the page. Returns the data to the JS code which then decides what it's going to with it, including clearing existing content, and outputting whatever it got from the PHP code.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
What Vacunita says is perfectly correct.

To make sense of this, you therefore may prepare your scripts to alternatively output just the html snippet of the content or a whole HTML page via parameter.
Javascript may use that, also a template engine might put together a whole page from parts it puts together or (more often) a whole template has placeholders where the missing html parts are injected.

Anyway, without any helper code working clientside (and javascript is the norm here) the usual request from the browser to the server via clicking a link renders the full page in either the same window/tab or a new target and needs a full html page returned.

One way out is iFrames, where page parts are their own full html page. While iFrames are not removed from html - even in html5 (actually here it really became a standard first time and framesets/frames were deprecated - they are avoided for different reasons also valid for framesets and frames - the term is cross site scripting and security issues of that) and a clean approach without iFrames and JS is returning full html pages, despite of the repeated parts of it. When you think about saving traffic, you have a thought of the previous decade if not century. You can already save much traffic by caching images and other stuff apart of the html.

Bye, Olaf.
 
Thanks all.
I'm quite familiar with ajax and even iframes and that's what I was thinking as well. The different situation is that the design was done by another developer who was not thinking for the whole. I wanted to get other opinions and you've supplied those. THANKS!
 
You're welcome.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top