views:

56

answers:

1

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?

+1  A: 

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.

ehsanul
Thanks, mate! That worked like a charm :-)
Fossmo