title: set jinja2 url_for as an href in getJSON callback
body: <p>I am working inside a jquery, getJSON callback function using flask as my web framework.
  I am trying to set the link desination for a dynamically created dom element.  I want to set it to the jinja2 code for url_for.  So, I would like to do something like this:</p>
  
  <pre><code>a.href ="{{ url_for('write_response', id=".concat(data.libArticles[i].id.toString(), ") }}"); 
  </code></pre>
  
  <p>I have had the worst time doing this.  First, it would not recognize the "{{" and "}}" strings, removing them, opening quotes and doing other weird stuff because of those characters.  Finally, by doing this:</p>
  
  <pre><code>var url1 = "{url_for('write_response', id=".concat(data.libArticles[i].id.toString(),")}");
  var url2 ="{".concat(url1, "}");
  a.href = url2;
  </code></pre>
  
  <p>it finally accepted the string with two instances of "{", so it accepted "{{somethig}}"</p>
  
  <p>This still did not work and instead, when the link is clicked, it redirects to the following and fails :</p>
  
  <p><a href="http://localhost:5000/write_response/%7B%7Burl_for" rel="nofollow">http://localhost:5000/write_response/%7B%7Burl_for</a>('write_response',%20id=3)%7D%7D</p>
  
  <p>Does anyone know how to do this?</p>