php/ajax question



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
.



Relevant Pages

  • Re: [PHP] php/ajax question
    ... Mixing Location and Cookie headers has always been hit and miss... ... I have a small php script that behaves differently depending upon ... then the $_SESSION var is filled with "text" and the redirect is ... if the php script is called via ajax: ...
    (php.general)
  • Re: [PHP] storing / processing login info (newbie stuff not intutorials)
    ... can i save this info in a file and have my php script either include or call ... how can authcheck.php redirect the user to... ... files that does certain things like setup the db connection, ... set a session var that shows that they are loggedin and use ...
    (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: Can you do this with PHP?
    ... Basically the AJAX routine calls a PHP script. ...
    (comp.lang.php)
  • Re: Can you do this with PHP?
    ... Basically the AJAX routine calls a PHP script. ...
    (comp.lang.php)