If you make a header redirect via PHP your whole ajax request redirects. If 
you request your mail.php and make something like this in it:

header("Location: news.php");
exit;

You will get the contents of news.php back in your request. If you like to 
redirect the user to a whole other page you have to do it with javascript. 
So return the URL you want to redirect to and set it to window.location as 
you did in the one example. Problem is if you don't wanna redirect the user 
anywhere because your server validation failed or something like this 
(which i hope so, because otherwise you don't need an ajax request and 
could send the form directly to the php file which does the redirecting and 
you would have to do 1 request less). Then you might want to display an 
error message. In this case you should return an JSON Object with a status 
or action. Something like this:

Redirect:
{
    'action': 'redirect',
    'url': 'news.php'
}

Display error:
{
    'action': 'displayError',
    'message': 'E-Mail address isn't valid'
}

Then you have a lot of flexibility for your purpose.

Best,
Steffen

On Wednesday, February 13, 2013 12:45:21 PM UTC+1, Hamburger wrote:
>
> Hallo Andrea,
> the doc/pdf is only an example.
> My reale case is, that I have different payment-methods. (If you dig into 
> schreibsmir.com you will find the payment-methods) Most of them gets an 
> answer via ajax witch I show direct on my page. Others like paypal needs to 
> be redirected to the paypal.page. I would like to handle all methods in my 
> php-script without touching my javascript.
>
> I found this somewhere else:
> That's not possible.
> HTTP is a stateless protocol, there's always one request, one response. If 
> you use AJAX, your script issues one request, and gets one response. Your 
> browser recognizes the 302 status and issues the next request, following 
> the redirection, and returns only the final response to your script.
> Is that really the way it works?
> How do others this?
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mootools-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to