将序列化数据附加到JSON对象

时间:2013-01-25 10:29:04

标签: javascript jquery ajax json

我有一个名为company

的序列化表单
$("#company_form").serialize();

post post中的参数看起来应该

company[name]   company name

现在我需要将另一个序列化表单附加到公司JSON对象。到目前为止,我尝试以相同的方式序列化user form并将其添加为

company.user = user

并且它附加了它,但参数没有序列化好,它们看起来像

name    name=name&email=test%40test.com

而不是

user[email] test@test.com    
user[name]  name

如果请求在日志文件中成功,我应该看到类似

的内容
{"company"=>{"name"=>"Hahn-Orn", 
             "tagline"=>"transform dynamic supply-chains", 
             "bio"=>["Tenetur non ex aliquam et. Autem velit consequatur et ea aut quos    debitis. Nulla quia impedit deserunt nesciunt. Dolores ipsam quod dolores id maiores. Atque iste quis nihil velit.", "Ducimus soluta omnis facilis illum nihil aspernatur. Aut quasi qui libero et sed. Fuga nesciunt dolorem.", "Ducimus itaque harum. Dolor officia labore rerum ullam. Veniam omnis et aut excepturi ut."]}, 
             "user"=>{"name"=>"Isabelle Schuster",
             "email"=>"jonathan_smith@example.com", 
             "password"=>"[FILTERED]", 
             "password_confirmation"=>"[FILTERED]"}}

0 个答案:

没有答案