我想向Rails 3服务器发送JSON POST请求。我有以下Ajax请求:
$.ajax({
type: 'POST',
contentType: "application/json",
url: url,
data:{email:“example@test.com”,password:“password”},
success: onSuccess,
error: onError,
dataType: "json"
});
但是,Rails服务器接收到的数据如下所示:
{"_json"=>["object Object"]}
我希望它能接收到:
{"email"=>"exmaple@test.com", "password"=>"[FILTERED]"}
我认为这是因为如果内容类型为JSON,jQuery会将数据包装在_json对象中。
有人知道我该怎么做吗?