Re: [PHP] php/ajax question




Mixing Location and Cookie headers has always been hit and miss...

I think you could fix it with session_write_close() or you could just
replace the Location: with:
require 'b.php';
since you are just wasting HTTP connections the way you have it now...


On Sat, December 30, 2006 12:56 pm, tedd wrote:
Hi gang:

I have a small php script that behaves differently depending upon
who's calling it. The code is:

<?php session_start(); /* a.php */
ob_start();
$_SESSION['var'] = "test";
ob_clean();
header("Location: http://www.example.com/b.php";); /* Redirect browser
*/
exit; ?>

If the code is called directly, namely http://www.example.com/a.php,
then the $_SESSION var is filled with "text" and the redirect is
realized.

However, if the php script is called via ajax:

-snip- preceding ajax

function sndReq(action)
{
http.open('get', 'a.php');
http.send(null);
}

Then the $_SESSION var is filled with "test", but the redirect is not
realized.

Why can't the php script redirect the browser when called via ajax ?

Thanks.

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
.



Relevant Pages

  • php/ajax question
    ... I have a small php script that behaves differently depending upon who's calling it. ... if the php script is called via ajax: ... Then the $_SESSION var is filled with "test", but the redirect is not realized. ...
    (php.general)
  • Re: Setting up a page that will intercept all pages that do not already exist?
    ... >Using the ErrorDocument 404 syntax to redirect everything not found to ... >a PHP script will issue a 404 header to the browser, ... >the header is followed by html. ... REDIRECT_* variables if the error document is a CGI or PHP script; ...
    (comp.lang.php)
  • Re: How to get intermediate script results to browser?
    ... > I am playing around with it now on my local machine, and I try to put this ... > before my loop which does the mailing to all the subscribers in the ... To get PHP to do the redirect immediately instead ... What I need to find out now is how to get a PHP script to redirect the ...
    (alt.php)
  • Re: what is the correct/nice way to exit php CGI script running on a web server?
    ... >to redirect the users browser to the login screen. ... >main question is about the trick of calling exitat the end, ... > required to stop the php script that includes the above code from ...
    (comp.lang.php)
  • Re: old question (perhaps): redirect with POST of data?
    ... >>I'd like my PHP script to redirect the client browser to another page, ... >>It's a little annoying because plain redirecting is easy and plain POST ... > The following will redirect a POST request. ...
    (comp.lang.php)