1
AJAX請求這是我的看法HAML的片段:參數在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請求 '/如何名稱=一些'?。如何將輸入字段值傳遞給此ajax請求?
非常好。如果可能的話,我會加倍投票。 – demas 2012-03-29 13:48:23
@demas。您可以在'meta'上索要... :)感謝您的反饋。 – gdoron 2012-03-29 13:53:54