views:

44

answers:

1

I'm sending a request from jquery and expecting json response. Configuration is like this:

        type: 'POST',
        cache: false,
        iframe: true,
        dataType: "json",

Now there's a funny thing. When I return data as text, it works fine:

render :text => "{}"

But when I use :json option, firefox prompts me to download file containing exactly two characters, {}. Success callback is never invoked.

render :json => {}

Since there's already a workaround (see above), the question has only theoretical value. Did it ever happen to you?

A: 

It's probably due to that you are setting iframe to true, so firefox shows the download prompt, either set

    iframe: false,

otherwise you have to make rails send the text/plain header by using

    render :text => "{}"

Regards.

Amer