为什么render\u模板不起作用我正在尝试制作一个登录表单,在成功登录后返回主页
这是我的ajax代码 你知道吗
$(document).ready(function() {
$('.logBtn').click(function() {
$.ajax({
data : {
email : $('#emailInput').val(),
password: $('#passInput').val()
},
type : 'POST',
url : '/process'
})
.done(function(data) {
if (data.error) {
$('#errorAlert').text(data.error).show();
$('#successAlert').hide();
}
else {
$('#successAlert').text(data.name).show();
$('#errorAlert').hide();
}
});
event.preventDefault();
});
});
</script>
这是Python
@app.route('/process', methods=['POST'])
def process():
email = request.form['email']
password = request.form['password']
if password and email:
user = Db().login(email, password)
if user:
session['user'] = user
session.modified = True
return render_template("home.html", user='user')
return jsonify({'error' : 'Incorrect username and password.'})
目前没有回答
相关问题 更多 >
编程相关推荐