我在haml文件中有以下select_tag:
= select_tag 'setup_form_popup', options_for_select([ ["No Setup Time","0"],
["15 Minute", "15"], ["30 Minute", "30"], ["45 Minute", "45"],
["60 Minute", "60"], ["75 Minute", "75"], ["90 Minute","90"],
["105 Minute", "105"],["120 Minute","120"]], @event.setup_time),
{:prompt => 'Setup Time'}
如何通过ajax请求中的数据属性访问服务器?以下代码段:
var setup_time_update = $.ajax({
url: '/calendar',
dataType: 'json',
type: 'PUT',
data: "What do I put here?";
});
ajax的新手仍然在学习绳索。很棒的技术。欢迎任何和所有帮助。干杯〜
答案 0 :(得分:0)
// Get value of select tag
var setup_form_popup_value = $("#setup_form_popup").val();
$.ajax({
url: '/calendar',
dataType: 'json', // Are you expecting json from server? If you want to execute javascript returned from server then dataType should be 'script'.
method: 'PUT',
data: { setup_time: setup_form_popup_value } // You will get params[:setup_time] in your controller.
});