title: Generating routes in javascript with Twig and Symfony2
body: <p>Quite odd problem, sorry for asking, i'm quite new to Symfony/Twig. My route requires a mandatory <code>region_id</code> paramenter:</p>
  
  <pre><code>ajax_provinces_by_region:
    pattern: /ajax/region/{region_id}/provinces
    defaults: {_controller: SWAItaliaInCifreBundle:Ajax:provincesByRegion }
    requirements: {region_in: \d+}
  </code></pre>
  
  <p>The <strong>question</strong> is: how can i generate this route based on a <code>select</code> element in javascript (code below)?</p>
  
  <p>The <strong>problem</strong> is: i can't use <code>path</code> and <code>url</code> helpers from Symfony as they require to specify the <code>region_id</code> parameter (<code>this.value</code>) i can't access because it's a javascript variable (and Twig is compiled server-side).</p>
  
  <pre><code>$(document).ready(function() {
      $('select#regions').change(function(){
  
          // Make an ajax call to get all region provinces
          $.ajax({
              url: // Generate the route using Twig helper
          });
  
      });
  });
  </code></pre>