0

I need to redirect to a page using php.

i am passing an ajax request to a php page, and based on the request sent i need the php to redirect to another page. is it possible?

user475685
  • 8,041
  • 7
  • 26
  • 24

2 Answers2

2

On success event of ajax request you have to get requested param from response (an url or params, etc) and call in JavaScript:

window.location = 'http://google.pl';
hsz
  • 148,279
  • 62
  • 259
  • 315
  • i don't want it on success, i want it to be performed in the php itself – user475685 Mar 17 '11 at 12:31
  • 2
    If you want redirect page on which you use ajax requests you have to do it in JS too. It is impossible to do this just in PHP to redirect. If you do request to `test.php`, any PHP redirect contained in `test.php` will only provide you other output. If in `test.php` you set redirect to `test2.php`, only thing you will achieve is output from it in main page in success event. – hsz Mar 17 '11 at 12:35
0

To redirect to another page in php (this does not require ajax):

How to make a redirect in PHP?

Community
  • 1
  • 1
Paul
  • 6,572
  • 2
  • 39
  • 51