Problem redirecting from a js call

Hi all,

I have a form that uses ajax to add a product to a cart. After all verifications it must redirect to the product page again.

When I call the js, it makes all the verifications, if one fails, it renders them in a specific div with the explanation, but if there are no errors, it must redirect to the product again, so I used the typical:

redirect_to @product

but since it was a js call the redirect tryes to render the js template for @product but it not exists since it's only html.

So, ¿how can I tell redirect_to to render the html format instead of the js format on the redirection?

So many thanks in advance.


Sorry if my English it's not good enough, I try my best :slight_smile:

Found how to do it.

window.location.replace( url-to-go ); in the template. Was looking to do this inside the controller but this works too.