【发布时间】:2009-07-05 13:00:27
【问题描述】:
我正在尝试将以下数据发送到服务器,但在服务器端我没有看到我正在发送的 json 参数。谁能告诉我我做错了什么?
您可以在下面看到代码。
原型:
send_data_url = "change"
hash = $H({"blocks": [{"h": "2", "area": [{"width": "96%", "els": [{"title": "first", "mand": true}, {"title": "second", "mand": false}]}]}]});
var request_array_json = hash.toJSON();
new Ajax.Request(send_data_url, {
method: 'post',
parameters: request_array_json,
contentType: 'application/json;'
});
导轨:
def change()
debugger
my_json = ActiveSupport::JSON.decode(params["_json"])
end
在控制器中,我看到 params 对象没有 json 参数。
它只显示动作和控制器:
{"action"=>"change", "id"=>nil, "controller"=>"default/test"}
注意:我使用的是原型 1.6 qnd rails 2.3.2。
【问题讨论】:
标签: ruby-on-rails json prototypejs