我正嘗試使用form_for:remote => true更新div,但沒有發生。下面給出的是我的代碼406在使用form_for時,不可接受的錯誤:remote => true在rails中使用jquery 3
monhtly_report.html.erb
<%= form_for(:monthly_detail, :url => product_report_monthly_details_path,:remote => true) do |f|%>
<table class="form-table">
<tr>
<td width="80px">
Product
</td>
<td colspan="2">
<%= f.collection_select(:product_id, @products, :id,:name, :prompt => true)%>
</td>
</tr>
<tr>
<td>
Month
</td>
<td>
<%= select_month(Date.today, :field_name => 'selected_month') %>
<%= select_year(Date.today, :start_year => 2000, :end_year => 2020, :field_name =>'selected_year') %>
</td>
</tr>
<tr>
<td></td>
<td>
<%=submit_button_tag 'Submit'%>
</td>
</tr>
</table>
<%end%>
<div class="monthlyreportsection">
</div>
,這是我的控制器
def product_report
@details = MonthlyDetail.find_by_product_id(params[:monthly_detail][:product_id].to_i)
@time = Date.new(params[:date][:selected_year].to_i, params[:date][:selected_month].to_i,1)
respond_to do |format|
format.js
end
end
PS:請求將控制器作爲HTML,而它必須是JS
the product_report.js.erb
$("#monthlyreportsection").html("<%=escape_javascript(render(:partial => "product_details"))%>")
我的實際問題是div沒有上傳。幫幫我。提前致謝。