Switching response formats

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!

On Thursday, 6 February 2014 16:52:12 UTC-5, bertly_the_coder wrote:

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?

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 J.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs