title: Passing Ajax Parameters to Rails Controller
body: <p>I am trying to pass some parameters from my view via an AJAX call to a custom method fetch_info in my photos controller. My controller does not seem to be receiving the parameters. When I click on an image to initiate the AJAX call, I see the following in my terminal:</p>
  
  <pre><code>Processing by PhotosController#fetch_info as JSON
    Parameters: {"id"=&gt;"", "secret"=&gt;""}
  Completed 500 Internal Server Error in 267ms
  
  FlickRaw::FailedResponse ('flickr.photos.getInfo' - Photo not found):
    app/controllers/photos_controller.rb:38:in `fetch_info'
  </code></pre>
  
  <p>It looks like the fetch_info method is being called, but the parameters are empty. How should I be passing in my parameters through AJAX?</p>
  
  <p>Here is my view. I also have my javascript in the view for the purpose of just getting this to work.</p>
  
  <p>index.html.erb</p>
  
  <pre><code>&lt;div class="body_container"&gt;
  
      &lt;div id="photos_container"&gt;
      &lt;% @photos_array.each do |p| %&gt;
  
       &lt;%= link_to '#' do %&gt;
         &lt;div class='each_photo_container', id='&lt;%="#{p[:id]}"%&gt;' &gt;
           &lt;%= image_tag p[:s_url] %&gt;
         &lt;/div&gt;
       &lt;% end %&gt;
  
      &lt;!-- Load Modal onClick --&gt;
      &lt;script type="text/javascript"&gt;
      jQuery(function() {
       $('#&lt;%=p[:id]%&gt;').click(function (e) {
  
          //ajax call to fetch photo info
          var fetch_id = '&lt;%=p[:id]%&gt;';
          var fetch_secret = '&lt;%=p[:secret]%&gt;';
  
          $.ajax({
            type: 'GET',
            url: '/photos/fetch_info',
            dataType: 'json',
            data: { 'id' : fetch_id.val(), 'secret' : fetch_secret.val() } 
          });
  
          return false;
        });
      });
  
      &lt;/script&gt;
  
      &lt;% end %&gt;
  
      &lt;div class="basic_modal"&gt;
      &lt;/div&gt;
  
   &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is my photos_controller.rb:</p>
  
  <pre><code>  def fetch_info
      puts params[:id]
      puts params[:secret]
  
      info = flickr.photos.getInfo(:photo_id =&gt; params[:id], :secret=&gt; params[:secret])
  
  
    end
  </code></pre>