【发布时间】:2016-12-23 05:53:44
【问题描述】:
我遇到了一个奇怪的问题,导致控制台在解析后不显示输出
a= "<%=j render 'api/restaurants/index.json.jbuilder',restaurants: @restaurants %>";
json = $.parseJSON("<%= render 'api/restaurants/index.json.jbuilder', restaurants: @restaurants %>");
console.log(json);
a= "<%=j render 'api/restaurants/index.json.jbuilder', restaurants: @restaurants %>";
json = $.parseJSON("<%= render 'api/restaurants/index.json.jbuilder', restaurants: @restaurants %>");
console.log("console test");
a= "<%=j render 'api/restaurants/index.json.jbuilder', restaurants: @restaurants %>";
json = $.parseJSON("<%= render 'api/restaurants/index.json.jbuilder', restaurants: @restaurants %>");
console.log(a);
上面的代码 sn-ps 不会在控制台中呈现任何内容,但是下面的代码 sn-ps 会给出控制台输出。
a= "<%=j render 'api/restaurants/index.json.jbuilder', restaurants: @restaurants %>";
console.log(a);
a= "<%=j render 'api/restaurants/index.json.jbuilder', restaurants: @restaurants %>";
console.log("console test");
似乎解析正在阻止控制台输出任何内容。任何人都知道为什么会发生这种情况以及如何解决它
【问题讨论】:
-
"<%= rende和其他东西在我看来不像 json。我得到 'Unexpected token
标签: javascript ruby-on-rails json jbuilder