switching response formats

15 views
Skip to first unread message

bertly_the_coder

unread,
Feb 6, 2014, 4:52:12 PM2/6/14
to rubyonra...@googlegroups.com
Hi guys,

Is this possible? I have an action triggered off as JS, which i respond to appropriately, but sometimes, the request fails at which point I'd like to change to respond_to format to html so that I can redirect to a thank you page. So far I've tried: 
redirect_to(thank_you_path, format: 'html') and return if @next_question.nil?
but this still tries to redirect it as a js response, which of course fails......is there anyway I can convert a JS request to an HTML response? 

Thanks for your help!

Matt Jones

unread,
Feb 7, 2014, 10:26:56 AM2/7/14
to rubyonra...@googlegroups.com
I don't think this would work, even if it was possible - the code on the web browser end is still expecting a JS response, and trying to execute HTML as Javascript will not turn out well.

As an alternative, what if you rendered some JS that changed `window.location` to the thank-you page? (sometimes described as a "client-side redirect")

--Matt Jones 
Reply all
Reply to author
Forward
0 new messages