Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

ajax onclick then redirect



11:39 am on Aug 3, 2008 (gmt 0)

5+ Year Member


so I use ajax to validate form input, whenever user click on the "submit" button which I attached an "onclick" event to it, it calls the ajax function to the php validation script.

after everything is ok, I was able to add user's post into database, but the current page just sits there, it won't redirect user to another page, "index" page let say.

so how do I do this? I want to redirect user to some other page after let say they post a topic, but using ajax only check for onclick event. If I attached an onsubmit event, my ajax won't work anymore.

I'm new to ajax and javascript.



6:57 pm on Aug 3, 2008 (gmt 0)

5+ Year Member

i got it.


answer: so we can't redirect (using server side code) to a different page after submitted a form using ajax to validate because that's the whole point of using Ajax in the first place. We can add a window.location to ajax handler to redirect.


2:27 pm on Aug 13, 2008 (gmt 0)

5+ Year Member

Yes thats right, you should use server side code.

Don't forget with AJAX and update panels, you must use Response.Redirect instead of Server.Transfer because that just falls over! :)


Featured Threads

Hot Threads This Week

Hot Threads This Month