Welcome to the Treehouse Community
Looking to learn something new?
How to redirect user away from page form data was sent to?
When sending a form in HTML, the action attribute is where the form data is sent to, but it is also automatically where the user is redirected to when the form is submitted. However, I don't want the user viewing a php page where I process the form data, so how can I redirect them to another page while still maintaining the destination of the form data?
Steven Parker216,164 Points
Normally, it's the server's job to determine what is sent back to the browser when a form is received. This would include redirection.
But if you can't take care of this the normal way for some reason, you could use AJAX to submit your form instead of the normal mechanism, and then direct the browser wherever you like by changing the location property of the window (more specifically, location.href).