Topic: Help moving JS from the view to the .js file


I have a view in which there is a table.  For each rows, I have to query a web service and since it's a little long, I did some ajax that will render the page, then update a div inside each row with the web service answer.  The JS code is currently in the view itself and I'd like to move it to application.js or but can't get it to work.

My view has

<% @thisthing.each do |b| %>
<% @thisotherthing.each do |c| %>

then a table where each row has :

Some interesting things shown here and another line with
<div id="bug_<%= %>"> Loading </div> 

at the end of this view, I have the following

<% @thisthing.each do |b| %>
<% @thisotherthing.each do |c| %>
<% if == c.bug_id  %>
      url: "/top10/wscall?name=<%= c.value %>",
      cache: false,
      success: function(html){
        $("#bug_<%= %>").replaceWith(html);
<% end %>
<% end %>
<% end %>

It works but I would like to move this ajax stuff at its proper place.  I tried the data-url kind of stuff found on … javascript but it doesn't work and I believe it's because of my c.value or that the JS file doesn't know about...