Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
Rails variable in Ajax
<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) %>",
    })
  })

Error: undefined local variable or method `data' for #ActionView::Base:0x00000000017430

How can i pass "data" variable to <%= %> tag. Thank you!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You try this way.

  <%= 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 %>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!