Ajax 表单在 Ruby Rails returns 上提交 400 错误请求
Ajax form submit in Ruby on Rails returns 400 Bad Request
我有一个要使用 Ajax 提交的表单。现在我收到错误状态 400 Bad Request。
表格为:
<%= form_tag client_contacts_path, role: 'form', id: 'nested_client_contact_form', remote: true, method: 'post' do |f| %>
我 ajax 调用表单提交:
$('#nested_client_contact_form').submit ->
valuesToSubmit = $(this).serialize()
$.ajax(
type: 'POST'
url: '/client_contacts ',
contentType: 'application/json'
data: valuesToSubmit
dataType: 'json').success (json) ->
# some code
return
false
这应该会创建新的客户联系人并保留在页面上。没有重定向。
最后它仅通过使用 remote: true 而没有使用 CoffeeScript
我有一个要使用 Ajax 提交的表单。现在我收到错误状态 400 Bad Request。
表格为:
<%= form_tag client_contacts_path, role: 'form', id: 'nested_client_contact_form', remote: true, method: 'post' do |f| %>
我 ajax 调用表单提交:
$('#nested_client_contact_form').submit ->
valuesToSubmit = $(this).serialize()
$.ajax(
type: 'POST'
url: '/client_contacts ',
contentType: 'application/json'
data: valuesToSubmit
dataType: 'json').success (json) ->
# some code
return
false
这应该会创建新的客户联系人并保留在页面上。没有重定向。
最后它仅通过使用 remote: true 而没有使用 CoffeeScript