當我用$.ajax()
與以下respond_to
塊提交表格的內容:爲什麼刪除respond_to後「已完成406不可接受」已經消失?
respond_to do
render :json => { :url => question_path(resource, :recent => :true),
:uploadPath => question_path(@question, :format => "json"),
:editPath => edit_question_path(@question),
:exitPath => question_path(resource)
}
end
我有一個錯誤:
Completed 406 Not Acceptable in 124690.7ms (Views: 0.4ms | ActiveRecord: 16.7ms | Sphinx: 0.0ms)
後我除去respond_to
,作爲上述代碼被改變爲:
render :json => { :url => question_path(resource, :recent => :true),
:uploadPath => question_path(@question, :format => "json"),
:editPath => edit_question_path(@question),
:exitPath => question_path(resource)
}
錯誤消失了,爲什麼會發生這種情況?我錯過了什麼?謝謝!
您的詳細解釋讓我終於理解'respond_to'和'* .html/json'之間的關係,謝謝 – abelard2008