title: Laravel 4, Pass a variable to route in javascript
body: <blockquote>
    <p>How Can I pass the variable (stock.id) return from Ajax response to the route to generate the url to edit a stock</p>
  </blockquote>
  
  <pre><code>$.ajax({
              url: 'sectors/stocks/' + $(this).data('sector-id'),
              dataType:'json',
              beforeSend:function() {
                  $('.stocks_list').html('Loading...');
              }
          })
          .done(function(data) {
              $('.stocks_list').html('&lt;ul&gt;');
              $.each(data, function(index, obj_data) {
                  $.each(obj_data.stocks, function(indx, stock) {
                      $('.stocks_list').append('&lt;li&gt;&lt;a href="{{route("admin.stocks.edit","'+stock.id+'")}}"&gt;' + stock.symbol + ' &lt;/a&gt;&lt;/li&gt;');     
                  });
          });
      })
  </code></pre>