Redirect page using PHP + jQuery

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Bbob
Forum Commoner
Posts: 57
Joined: Sat Aug 07, 2010 4:46 am

Redirect page using PHP + jQuery

Post by Bbob »

Hi

Im using jQuery to get the values from a form and pass to PHP for validation. Once validations are ok, how do I redirect to another page?

Using PHP header(location) doesnt seem to work.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Redirect page using PHP + jQuery

Post by Eran »

JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Redirect page using PHP + jQuery

Post by JakeJ »

Or just use the jquery load() function.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Redirect page using PHP + jQuery

Post by Eran »

JakeJ wrote:Or just use the jquery load() function.
What does that have to do with redirection?
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Redirect page using PHP + jQuery

Post by JakeJ »

Because you can use it to load another page. It's an ajax request.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Redirect page using PHP + jQuery

Post by Eran »

You can use it to load new HTML in the current page, not to redirect to another page.
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Redirect page using PHP + jQuery

Post by JakeJ »

I understand that, but if someone doesn't know that function exists, it might be a better option. Just because someone says "redirect" doesn't necessarily mean an actual redirect is the best option.

We've all used terms not being aware of other options. If the OP doesn't find it useful, no biggie, but it's an option to explore no?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Redirect page using PHP + jQuery

Post by Eran »

You need to be clear then in what you mean, especially if you believe the OP does not know the difference. The way you wrote it seems to be another way to redirect the page. Personally, I believe redirecting after a successful form submission is the correct approach
Post Reply