Link to home
Start Free TrialLog in
Avatar of Pedro Chagas
Pedro ChagasFlag for Portugal

asked on

Redirect page after send variables in Ajax and PHP

Hi E's, I have two pages, index.php and ajax.php, and in index.php I send variables via Ajax to ajax.php to be processor, and I use this line of code to do that in js:
$.post("ajax_processar.php",{"redirect":\'1\'},function(data, textStatus, jqXHR){});

Open in new window

When ajax.php receive the variable "redirect" what the script have to do is redirect the page index.php to somenewpage.php:
if($_POST["redirect"] == 1){
//redirect index.php to somenewpage.php ???????????
}

Open in new window

The solution can be in js also.
How I do this?

The best regards, JC
SOLUTION
Avatar of Greg Alexander
Greg Alexander
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Pedro Chagas

ASKER

Hi @galexander07, first thanks for answer.
I know redirect page in the same page, but in my particular case I need that redirect come from the page of Ajax.php and don't from index.php.
In practice what I want to do is check some error that occurs in ajax.php, and I detect the errors if the page is redirect, like somenewpage.php?zone=1, somenewpage.php?zone=2, somenewpage.php?zone=3 and so on...
For you understand, Ajax.Php receive lots of variables from index.Php via ajax, and Ajax.php will process that variables with a lot of conditionals, and something wrong happens, because the script no respond always in the same way, and I need to know in what zone of the script the error occurs.
That is the reason I need to redirect the page and the order have to come from Ajax.Php and not from index.Php.
Have a solution?
The best regards, JC
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial