title: How to render a partial and instance variable via ajax?
body: <p>Is it possible to render a partial and the model's data retrieved with just one ajax request?</p>
  
  <pre><code># app/models/store.rb
  def index
    user    = current_user;
    @stores = Store.where(:user_id =&gt; user.id)
  
    render :partial =&gt; "stores", :layout =&gt; false 
  end
  
  # app/views/stores/_stores.html.erb
  &lt;div class="stores"&gt;
    &lt;select id="stores" class="dropdown"&gt;
      &lt;% @stores.each do |store| %&gt;
        &lt;option value="&lt;%= store.id %&gt;"&gt;&lt;%= store.name %&gt;&lt;/option&gt;
      &lt;% end %&gt;
    &lt;/select&gt;
  &lt;/div&gt;
  
  # app/views/users/index.html.erb
  $.ajax({
    type : "GET",
    url  : "/stores",
  
    success: function(data) {
      $("div").html(data); //rendering partial
      // how to get @stores variable??
    }
  });
  </code></pre>
  
  <p>Imagining that @stores has 3 items from user with id = 1, how can I access this data on ajax success callback?</p>