【发布时间】:2014-05-20 07:46:50
【问题描述】:
我想从带有文本区域的 HTML 页面发送一些 json 参数,并且我想发送写在这个文本区域中的 json 参数,例如格式。 {"name": "test", "description":"test", "price":100}
但是 rails 认为它是{"{'name' : 'test', 'description' : 'test', 'price' : 100}"=>nil} 我如何从文本区域发送 json 参数以从 rails 应用程序读取。
【问题讨论】:
-
你能把发送
json的code贴出来吗? -
你设置了吗?内容类型:application/json (hashcode.eti.br/?p=481)
-
当你提到你正在“发送”JSON 参数时——你是怎么做到的?你能详细说明你是如何发送它们的吗?
-
是的,我设置了 Content-Type: application/json 但 rails 不理解从文本区域(json 格式)传递的内容。你可以从这个示例中轻松理解
<input type='textarea' name='content' value='{"name": "test", "description":"test", "price":100}' id='text_content' />
标签: ruby-on-rails ruby ajax json ruby-on-rails-3