homepage Welcome to WebmasterWorld Guest from 54.161.202.234
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
ajax onclick then redirect
kpop




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

Hi,

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.

thanks.

 

kpop




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

i got it.

thanks.

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.

seodreamer




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

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! :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved