开发者

Rails 3.1 (rc4), AJAX and UTF-8

I believe this is OK, so I am creating a question that I have 开发者_高级运维the answer to for other peoples benefit. The problem:

I'm using a remote link to send a request for information and returning script containing that information. The data that comes back is for some reason encoded in ISO-8859-15 even though I have done everything I could find that would make Rails & Ruby use UTF-8.

show.coffee

$('#messages_messages').html("<%= escape_javascript(render 'show') %>")
# _show.html.erb will create output with characters such as åäö

The response contains a bunch of ?-characters instead of åäö.


For some reason this bug only happens when using the .coffee filename. This is my solution:

Don't use .coffee and the end of your filename. show.js.erb

$('#messages_messages').html("<%= escape_javascript(render 'show') %>");
# _show.html.erb will create output with characters such as åäö

No encoding errors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜