0
<script> var depart_date='11 February 2013';
         var depart_date='21 February 2013';
</script>


    jQuery.ajax({

data: { depart: depart_date, return_date: return_date},
    type: 'post',
  url: "/payment/create",

});

这是我的ajax调用。

在终端中,它的价值为 {"depart"=>"11 February 2013", "return_date"=>"21 February 2013"}

但在控制器中 params[:depart] & params[:return] 显示为nil值。

可以帮助我在哪里做错了吗?

4

1 回答 1

0

将您的ajax更改为以下

jQuery.ajax({
  url: "/payment/create",                     // you to pass this as the url option
  type: 'post',
  data: 'depart=' + depart_date,
  dataType: 'script',                         // this should be dataType, not dateType
  success: function() { alert('success') }    // this should be a function
});
于 2013-02-12T11:44:37.903 回答