Might be obvious, but still I'm lacking here of the basic knowledge.
所以在控制器内部,两者都可以使用,还是总是Javascript,所以两者都是一样的?
Might be obvious, but still I'm lacking here of the basic knowledge.
所以在控制器内部,两者都可以使用,还是总是Javascript,所以两者都是一样的?
在Rails 3.1中,我能发现的唯一区别是,如果格式化程序是js,那么答案将以纯文本形式发送.如果是json,则将其编码为json.
如果是format.json
format.json {
render :json => @accounts.map(&:attributes)
}
server send:
data:application/json;base64,
如果是格式.js
format.js {
render :json => @accounts.map(&:attributes)
}
server send:
[{"id":33,"email":"user1@example.com"}]