我有这个$ .ajax方法调用:
var w_command = "add_holiday"
var w_type = "POST"
var w_id = "123321"
$.ajax(
{
type: w_type,
url: w_command,
parameters:
{
to_find_id: w_id
},
success:function()
{
//Do something on success
alert('done');
}
});
从控制器调用此方法:
def add_holiday
RHoliday.create(holiday_id: params[:to_find_id].to_s, group_id: @group.id.to_s)
end
我也得到alert('done');
告诉我,AJAX请求有效,并找到方法。
那为什么它仍然没有创造任何东西呢?
编辑:
Started POST "/groups/133978052/add_holiday" for 127.0.0.1 at 2014-04-03 12:58:54 +0200
Processing by GroupsController#add_holiday as */*
Parameters: {"to_find_id"=>"4", "group_id"=>"133978052"}
←[1m←[36mUser Load (0.0ms)←[0m ←[1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1←[0m [["id", 99119911]]
Redirected to http://localhost:3000/
答案 0 :(得分:2)
没有任何名为parameters
,只有data
$.ajax({
type : w_type,
url : w_command,
data : {
to_find_id: w_id
},
success:function() {
//Do something on success
alert('done');
}
});