0
我在rails 3.1項目中使用jQuery。我使用的是button_to有:遙控=>真:rails 3 jquery button_to遠程json不解碼
<%= button_to "View Examples", "#{requisition_assign_path(@req.id, category_row.id)}?show_examples=1", :remote => true, :method => 'get' %>
這得到服務器的罰款,並在這裏進行處理:
def show
@assignment = Assignment.find params[:id]
@tag = @assignment.assignee
examples = []
@tag.example[@tag.tag].each do |e|
examples << {:id => e.id}
end
@examples_json = examples.to_json
respond_to do |format|
format.js {render "assign/show.js.erb"}
end
end
其中要求show.js.erb就好:
alert(jQuery.parseJSON("<%= @examples_json %>");
但在瀏覽器中,文本到達,但我無法得到它解析到原始散列數組。我錯過了什麼?
----我可能已經丟失的僅僅是使用jQuery的功能的getJSON ...