0

I have the following code on the server side which renders a JSON.

render json: {status: 1}, status: :ok

I would like to add support for rendering JSONP, how do I do that ?

I've tried the following code & it didn't work:

render :json => {status: 1}, :jsonp => params[:jsonp], :status => :ok

Edit:

I'm getting now the error: 'because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.'

How do I tell rails to server application/javascript then ?

Alon
  • 3,734
  • 10
  • 45
  • 64

1 Answers1

0

might be the following:

respond_to do |format|
  format.html { render json: {item: value}}
   if params[:callback]
     format.js { render :json => {item: value.to_json}, callback: params[:callback] }
   else
    format.json { render json: {item: value}}
   end
 end
Tim Kretschmer
  • 2,272
  • 1
  • 22
  • 35