I want to send a JSON request to rails 3 server. I have the following ajax request:
$.ajax({
type: 'POST',
contentType: "application/json",
url: url,
data: {email: "example@test.com", password: "password"},
success: onSuccess,
error: onError,
dataType: "json"
});
However, the rails server receives the data as follows:
{"_json"=>["object Object"]}
Where I want it to receive it as:
{"email"=>"exmaple@test.com", "password"=>"[FILTERED]"}
I think this is because jquery wraps the data with a _json object if the content type is json.
Does anyone know how I should do this?
source
share