Please, help me with problem: Flask don't want redirect after form submit. Code:
from flask import Flask, render_template, request, redirect, url_for
....
@app.route('/auth/')
def auth():
return render_template('auth.html')
This code work well:), auth.html render form:
{% extends "system.html" %}
{% block content %}
<form id="authen">
<input type="text" id="avtor_sku" pattern="[0-9]{1,13}" maxlength="13" value='' autofocus required>
</form>
{% endblock %}
Submit this form - over js-code:
$(document).ready( function(){$('#authen').submit( function(){ var avtor_sku = $("#avtor_sku").val();
data1= '' + avtor_sku;
$.ajax({type: "GET", url: "/auth_echo/", contentType: "application/json; charset=utf-8",
data: {auth_echo_value: data1}, success: function() {alert(1)}});
return false;});});
Alert(1) in this code - work. Route /auth_echo/:
@app.route('/auth_echo/', methods=['GET'])
def auth_echo():
return redirect(url_for('openday'))
Redirect not work. Why?