我不明白我在做什么错..
我正在尝试捕获未经授权的 401 并在使用提交按钮之前插入带有消息的 div
$(function() {
return $("a").ajaxError(function(event, jqXHR, ajaxSettings, thrownError) {
if (jqXHR.status === 401) {
$(".submit").before(<%=j content_tag :div, "Does not compute" %> );
}
});
});
文件名是 home.js.erb
甚至在页面加载之前我得到
JSON::GeneratorError in Pages#home
Showing H:/project/app/views/layouts/application.html.erb where line #6 raised:
only generation of JSON objects or arrays allowed
(in H:/project/app/assets/javascripts/home.js.erb)
第 6 行是指
5: <%= stylesheet_link_tag "application.css", :media => "all" %>
6: <%= javascript_include_tag "application" %>
显然出了点问题..但是什么?