我有一个表单,我收集表单数据,当我 serializeArray()这个表单我有这个:
[
{
"name": "authenticity_token",
"value": "HRjaGFRSqX6EqTYnyohQbc9g6P6RTsDgV3qizYuoh+E="
},
{
"name": "test[form_meta][index]",
"value": "0"
},
{
"name": "test[form_meta][location]",
"value": "http://localhost/static/test/password.html"
},
{
"name": "test[form_meta][title]",
"value": "Passwords Form"
},
{
"name": "test[form_meta][id]",
"value": "form1"
},
{
"name": "test[data][email[]]",
"value": "arnel@personal.com"
},
{
"name": "test[field_meta][email[]]",
"value": "test.place_detail_email"
},
{
"name": "test[data][password[]]",
"value": "test"
},
{
"name": "test[field_meta][password[]]",
"value": "test.alarm_password"
},
{
"name": "test[type][email[]]",
"value": "text"
},
{
"name": "test[label][email[]]",
"value": "Email Address:"
},
{
"name": "test[type][password[]]",
"value": "text"
},
{
"name": "test[label][password[]]",
"value": "Password:"
},
{
"name": "rec[email[]]",
"value": "test.previous_address_category"
},
{
"name": "rec[password[]]",
"value": "c_test.password[]"
}
]
这没关系。但是当我把它发送到我的控制器时:
$.ajax({
type: "post",
data: data,
success: function(){<code>},
error: function(){<code>}
});
我在我的控制器上得到了这个:
{
"authenticity_token"=>"HRjaGFRSqX6EqTYnyohQbc9g6P6RTsDgV3qizYuoh+E=",
"test"=>{
"form_meta"=>{
"index"=>"0",
"location"=>"http://localhost/static/test/password.html",
"title"=>"Passwords Form",
"id"=>"form1"
},
"data"=>{
"email"=>[
nil
],
"password"=>[
nil
]
},
"field_meta"=>{
"email"=>[
nil
],
"password"=>[
nil
]
},
"type"=>{
"email"=>[
nil
],
"password"=>[
nil
]
},
"label"=>{
"email"=>[
nil
],
"password"=>[
nil
]
}
},
"rec"=>{
"email"=>[
nil
],
"password"=>[
nil
]
},
"controller"=>"test",
"action"=>"create"
}
[nil] 数组在这里杀了我。我能做什么,不必改变形式,获得实际输入值,而不是 [nil] 值。
是否有解决此问题的方法