Вопрос

In all likelihood, this question reveals my gross misunderstandings of Rails, HTTP, and the internet.

Problem

I have a request hitting my server from a "transparent redirect" via Stripe API. The request is coming in as HTML format. I want to respond to it in JS format in an AJAX-esque way. My code looks like this:

def create
       .... other code ....
    render "attendances/create", formats: [:js]
end

I have a view file "attendances/create.js.erb." This successfully sends a response, but rather than the response executing the JS, the JS is instead rendered as HTML. It thus looks like plaintext JS.

Thank you for taking the time to consider this!

Это было полезно?

Решение

What are the request headers, Your ajax request must have accept request headers of javascript instead of default html, for it to allow/execute the js response directly.

See datatype here , it should be script

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top