Domanda

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!

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top