【发布时间】:2012-04-13 03:59:28
【问题描述】:
这是我的 HAML 视图的片段:
%script{:type => "text/javascript", :src => "assets/application.js"}
:javascript
$(document).ready( function() {
$('#post_action_trigger').click(function(event) {
$.get('/how?name=some', function(data) {
$('#answer').html(data);
});
});
} );
%body
%form
%label{:for => 'name'} Name:
%input{:type => 'text', :name => 'name', :class => 'text'}
%label{:for => 'notes'} Notes:
%input{:type => 'text', :name => 'notes', :class => 'text'}
%div{:id => 'post_action_trigger'}
现在,当我单击“post_action_trigger”-div 时,我的 javascript 发送 ajax 请求“/how?name=some”。如何将输入字段值传递到此 ajax 请求中?
【问题讨论】:
标签: jquery ruby ajax sinatra haml