i don''t even know if this is possible, so I''ll just ask. say I have a remote form. the form data gets submitted to the backend via AJAX. if there is a validation error in the form, i handle that on the AJAX side. however, if the form validates, I''d like to redirect the browser to a different page. Will a redirect_to work with an AJAX call or do I have to handle that a special way? ie class AjaxController < ApplicationController::Base def do_something #validate the form data redirect_to :controller => "xyz", :action => "abc" and return if data.validated? # otherwise, render the rjs template end end -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060316/4a8d7cd0/attachment.html
you need to check a result and if positive do a client-side redirect (javascript) On 3/16/06, Chris Hall <christopher.k.hall@gmail.com> wrote:> > i don''t even know if this is possible, so I''ll just ask. > > say I have a remote form. the form data gets submitted to the backend via > AJAX. if there is a validation error in the form, i handle that on the AJAX > side. however, if the form validates, I''d like to redirect the browser to a > different page. Will a redirect_to work with an AJAX call or do I have to > handle that a special way? > > ie > > class AjaxController < ApplicationController::Base > > def do_something > #validate the form data > redirect_to :controller => "xyz", :action => "abc" and return if > data.validated? > # otherwise, render the rjs template > end > end > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060316/8dc4d260/attachment.html
you can do def do_something #validate form data render :update { |page| page.redirect_to("/controller/action") } if data.validated? #otherwise render rjs template end On 3/16/06, Chris Hall <christopher.k.hall@gmail.com> wrote:> > i don''t even know if this is possible, so I''ll just ask. > > say I have a remote form. the form data gets submitted to the backend via > AJAX. if there is a validation error in the form, i handle that on the AJAX > side. however, if the form validates, I''d like to redirect the browser to > a different page. Will a redirect_to work with an AJAX call or do I have to > handle that a special way? > > ie > > class AjaxController < ApplicationController::Base > > def do_something > #validate the form data > redirect_to :controller => "xyz", :action => "abc" and return if > data.validated? > # otherwise, render the rjs template > end > end > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/02d719ce/attachment.html