Topic: Problems with extra Javascript ajax() parameters to my select function

Since I last posted I have made some progress on trying to get Rails, jQuery to play nicely.  As I said before, I have a analysis tool drop-down box that lets a user select an analysis tool.  Depending on the tool selected various bug information will be displayed in a list.  This is my select statement as well as the "div" that I want to change.

   <div class="analysistool" id="analysistool">
    <%= f.label "Analysis Tool" %><br />
    <%= f.select(:analysistool_id, 
                  options_from_collection_for_select(Analysistool.all, :id, :name,f.object.analysistool.try(:id)), 
                  {},
                  :onChange => "../reportviews.js();" ) %><br /> 
   </div>

  <div class="fieldlist" id="buglist">   // this is the div I want to change
    <table>  
         <%= render(Buginfo.where(:analysistool_id =>@reportview.analysistool_id)) %>
     </table>
  </div>

With the help of Firebug I have now been successful calling reportviews.js().    Here it is:

    $(document).ready(function(){
        $("#analysistool").change(function(){
           // Grab the id of the selected analysis tool and temporarily display it.
             var id = $("#reportview_analysistool_id").val()
          
           $.ajax({
             type: "POST",
             url: "/reportviews/update_buginfo_select",
           data:  ({
               id : id
             }),             
             success: function(result)
             {
                alert('hello');
             } 
            });

          });
      });

In my reportviews controller I wrote a function to render my partial.  The params[:id] should be from the javascript above

  def update_buginfo_select
     @buginfos = Buginfo.where(:id => params[:reportview][:buginfo_ids] , :analysistool_id =>params[:id])
    render :partial => "buginfos", :locals => {:buginfos => @buginfos}
  end

I also edited the routes.rb file and added:

    post 'reportviews/update_buginfo_select:id' => 'reportviews#update_buginfo_select'

I'm getting this error: ""NetworkError: 404 Not Found - http://localhost:3000/reportviews/update_buginfo_select?id=1&_=1334950051949"

The first parameter of 1 seems correct, but I'm not sure what the second parameter is
Any guidance would be deeply appreciated since I'm currently stuck.

Thanks.

Last edited by pwillemann (2012-04-20 15:31:15)