Reputation: 9842
I'm attempting to test a sample project at
http://162.243.232.223:3000/api/query
This is a rails project.
The rails controller is looking for a params hash like params[:query]['input']
In javascript, I am using jquery like this:
$.get('http://162.243.232.223:3000/api/query')
which get the expected default output.
However, I'd like to send in my own params more along the lines of this:
$.get('http://162.243.232.223:3000/api/query', { 'input': 'my_input' })
However, for whatever reason, this is returning errors, the
{ 'input': 'my_input' }
argument is not being passed as
params[:query]['input']
into Rails.
Any ideas on how I could start getting non-default responses back from Rails?
Thanks
Upvotes: 0
Views: 633
Reputation: 7666
In some cases when the server is not getting the input params like this how you had mentioned you need to apply this instead:
$.param({
json: JSON.stringify({
'input': 'my_input'
})
});
Upvotes: 0
Reputation: 4143
The way you have it now you would access it simply with params[:input]
. The params
hash gets all path, get and post variables in a single hash.
Upvotes: 1