I want to set rails to render .js.erb files by default for xhr requests.
1条回答 默认 最新
- weixin_33725807 2011-01-06 02:10关注
If you are using jQuery then update your rails.js to the latest from here https://github.com/rails/jquery-ujs and set the default request header for ajax calls with this:
$(function() { jQuery.ajaxSetup({ beforeSend: function(xhr) { xhr.setRequestHeader("Accept", "text/javascript"); } }); });
Here is a very recent commit for reference: https://github.com/rails/jquery-ujs/commit/fbbefa0773d791d3a67b7a3bb971c10ca750131b
解决 无用评论 打赏 举报