Reputation: 2892
I'm using JQuery to post in a Sinatra application.
$.post("/addnewlistitem", $('#inputrow1').val(), function(data){alert(data);});
Haml looks like this:
%input{:type => "text", :id => "inputrow1", :name => "item", :class => "txt"}
And the ruby code, like this:
post '/addnewlistitem' do
@v = params[:item]
end
The problem is that I can't get the data posted from JQuery. Any ideas?
Upvotes: 1
Views: 559
Reputation: 7766
Your issue is your jquery post. It should look like this:
$.post("/addnewlistitem", {item: $('#inputrow1').val()}, function(data){alert(data);});
Then it should all work. If not, I'll paste in my version of all this that I just tested.
Upvotes: 1