Re: php/ajax question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When you use "HEADER()", an HTTP header is sent to client browser. So when
using with an ajax call the header cannot redirect the page. For the purpose
you have to use include or require. If you want to redirect client browser
to some other location then you can work around with javascripts.

But when using ajax. headers cannot redirect client browser window.

Let me know if u need any more help

--- ORIGINAL ---
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";<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


--
Regards
Fahad Pervaiz
www.ecommerce-xperts.com

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux