0

我不明白我在做什么错..

我正在尝试捕获未经授权的 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" %>

显然出了点问题..但是什么?

4

2 回答 2

1

solved by removing the j..

which I don't understand... shouldn't j make it so I can put it in javascript?

于 2012-10-30T15:39:09.523 回答
0

May be a bug of execjs that time:

https://github.com/sstephenson/execjs/issues/129

Just update your execjs version to fix.

于 2014-10-17T07:40:47.480 回答