Flask: redirect(url_for()) returning html but not loading page
<p>I am building a small web app in Flask, a code excerpt is below. Basically, I am trying to store some data in <code>startsession</code> and then move on to <code>tagpage</code> once this is achieved. But <code>redirect</code> is not working. </p>

<p>When I run <code>TEST 1</code>, it displays <code>hello, world</code> in the console but the main page looks the same.<br>
When I run <code>TEST 2</code>, it displays the html in the console but the main page looks the same. </p>

<p>Here is what I have:</p>

<pre><code>@app.route('/startsession', methods=['POST'])
def startsession(): 
    _username = request.form['inputName']
    session['user_name'] = _username    
    ...
    return  redirect(url_for('tagpage')) 
</code></pre>

<p>Then, either:</p>

<pre><code>### TEST 1
@app.route("/tagpage")
def tagpage():
    return "hello, world"
</code></pre>

<p>Or:</p>

<pre><code>### TEST 2
@app.route("/tagpage")
def tagpage():
    return render_template('tagpage.html', filename=filename)
</code></pre>

<p>Sample of what I see after clicking the button that triggers <code>startsession</code>:</p>

<p><a href="https://i.stack.imgur.com/osw36.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/osw36.png" alt="enter image description here"></a></p>

<p>How can I get the browser to actually go to <code>http://localhost:5000/tagpage</code>?</p>

<p>UPDATE:
Here is my JQuery script:    </p>

<pre><code>$(function(){
    $("#btnStartSession").click(function(){     
        $.ajax({
            url: '/startsession',
            type: 'POST',
            data: $('form').serialize(),
            success: function(response){
                console.log(response);
            },
            error: function(error){
                console.log(error);
            }
        });             


    });
});
</code></pre>