<script type="text/javascript">
$(document).on("change","#status",function() {
var id_booking = $(this).attr('class')
data = $('option:selected',this).text().toLowerCase()
$.ajax({
type: "PATCH",
url: "<%= room_booking_path(room_id: 1, id: 1, status: data) %>",
})
})
错误:未定义的局部变量或方法' data'为#ActionView::Base:0x00000000017430
如何传递"data"变量<%= %>标签。谢谢你!
你试试这个。
<%= javascript_tag do %>
$(document).on("change","#status",function() {
var id_booking = $(this).attr('class')
data = $('option:selected',this).text().toLowerCase()
$.ajax({
type: "PATCH",
url: "<%= room_booking_path(room_id: 1, id: 1, status: data) %>",
})
})
<% end %>