tags:

views:

108

answers:

5

how i can i change the content of a page without refreshing.I know we need to use hidden frames for this but all the tutorials i have come across teach this only for HTML files what if the content is returned from a PHP file how do i do it in such a case? what should the php file echo or return?

A: 

If you use a hidden frame, the content won't be displayed (hence "hidden"), I think you just mean to use an iframe. But this doesn't fit your description of "without refreshing", since you have to refresh the frame.

When loading the PHP file inside the frame, your PHP file just needs to generate HTML the same way you would generate a normal page. It's the same whether the PHP file is loaded inside a frame or not.

Roy Tang
I believe he is referring the hidden frame AJAX pattern, where a hidden frame is used to handle the HTTP request. This pattern is sometimes used when the developer wants to allow the user to make use of the back/forward buttons in the browser to return to different states.
Jeff Fohl
+3  A: 

You will have to use Ajax for that, have a look at this tutorial:

Sarfraz
A: 

Hidden frames is one design pattern that is a part of the overall AJAX design pattern. This is an extreme high-level overview, but this is essentially how it works:

  1. Javascript in your HTML page makes a request to your PHP script by using an XMLHTTPRequest object, or a hidden frame or iframe. This is usually done asynchronously, so you can continue to work with your HTML page while the request is being made.

  2. The data is returned to your Javascript. At this point, you can then manipulate the page, and update data on the page using various DOM methods.

Jeff Fohl
A: 

use AJAX. Simple AJAX implementation can be found here, simple ajax tutorial

PradeepKr
+1  A: 
Dick Savagewood
Thanks this is the answer i needed :)
djd