title: Javascript redirect to dynamic url issue in Flask
body: <p>I have a 'puzzle' route with a dynamic url depending on the puzzle number that is working without issue:</p>
  <pre><code>@app.route(&quot;/puzzle/&lt;puzzle_id&gt;&quot;)
  @login_required
  def puzzle(puzzle_id):
      some sqlalchemy queries
      return render_template('puzzle.html', other variables)
  </code></pre>
  <p>I tried to do the same thing with an attempt route but using jquery javascript in the html to redirect:</p>
  <pre><code>-(jquery function above here that worked fine without the redirect)-
  }).done(function (response) {
      var attempt_num = response['attempt'];
      var urli = &quot;{{ url_for('attempt', attempt_num=attempt_num) }}&quot;;
      console.log(urli)
      window.location.href = urli;
  </code></pre>
  <p>for route:</p>
  <pre><code>@app.route(&quot;/attempt/&lt;attempt_num&gt;&quot;)
  @login_required
  def attempt(attempt_num):
      some sqlalchemy queries to fill variables
      print(&quot;render attempt template with attempt = &quot;+str(attempt.id),file=sys.stderr,flush=True)
      return render_template('attempt.html', other variables)
  </code></pre>
  <p>My print statement produces:</p>
  <blockquote>
  <p>render attempt template with attempt = 80</p>
  </blockquote>
  <p>and the flask server shows:</p>
  <blockquote>
  <p>127.0.0.1 - - [27/Mar/2021 19:50:27] &quot;←[37mGET /attempt/80?redir=True HTTP/1.1←[0m&quot; 200 -
  127.0.0.1 - - [27/Mar/2021 19:50:27] &quot;←[33mGET /attempt/ HTTP/1.1←[0m&quot; 404 -</p>
  </blockquote>
  <p>It looks like it is working correctly and trying to go to /attempt/80, but then it tries going to /attempt/ instead which isn't a defined route and causes a 404.</p>