Javascript 在Rails中处理ajax请求

Javascript 在Rails中处理ajax请求,javascript,jquery,ruby-on-rails,ajax,Javascript,Jquery,Ruby On Rails,Ajax,Stackoverflow社区 我的视图中有一个select。发送ajax请求的一次更改 指定选择的id并读取数据属性。 在数据变量中获取该数组,并将其传递给post ajax请求 var data = $(this).data('rtypes'); or $(this).find(':selected').data('rtypes') $.ajax({ type : "POST", url : "/RequestTypes/show_sub_types/"+rtype,

Stackoverflow社区 我的视图中有一个select。发送ajax请求的一次更改


指定
选择的
id
并读取
数据属性。
在数据变量中获取该数组,并将其传递给post ajax请求

 var data = $(this).data('rtypes');
 or
 $(this).find(':selected').data('rtypes')
 $.ajax({
   type : "POST",
   url :  "/RequestTypes/show_sub_types/"+rtype,
   dataType: 'json',
   data: JSON.stringify(data),
   dataType: "json", 
   contentType: 'application/json'
});