My form submits data through a sijax request and to acknowledge the submission I use obj_response. I tried both obj_response.alert() as well as obj_response.html() but nothing worked
My code:
from flask import Flask, render_template, request, flash, g, redirect, url_for
from flask_sqlalchemy import SQLAlchemy
import flask_sijax
import os
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///Login.sqlite3"
path = os.path.join('.', os.path.dirname(__file__), 'static/js/sijax1/')
app.secret_key = 'super secret key'
app.config['SESSION_TYPE'] = 'filesystem'
app.config['SIJAX_STATIC_PATH'] = path
app.config['SIJAX_JSON_URI'] = 'static/js/sijax/json2.js'
db = SQLAlchemy(app)
flask_sijax.Sijax(app)
class Signup(db.Model):
ID = db.Column("ID", db.String(10), primary_key=True)
Fname = db.Column(db.String(20))
LName = db.Column(db.String(20))
Password = db.Column(db.String(20))
def __init__(self, id, fname, lname, password):
self.ID = id
self.Fname = fname
self.LName = lname
self.Password = password
@flask_sijax.route(app, '/signup')
def home():
def caller(obj_response, values):
newuser = Signup(values['ID'], values['fname'], values['lname'], values['Password'])
db.session.add(newuser)
db.session.commit()
obj_response.html("#result", "Successfully signed up")
if g.sijax.is_sijax_request:
g.sijax.register_callback('call', caller)
return g.sijax.process_request()
return render_template("first.html")
@app.route("/success", methods=['POST', 'GET'])
def success():
records = db.session.query(Signup).all()
return render_template("second.html", records=records)
if __name__ == "__main__":
db.create_all()
app.run(host="127.0.0.1", port=2908, debug=True, threaded=True)
^{pr2}$My HTML file
我注意到Sijax在使用高于1.5.1的jQuery版本时停止工作 所以试着替换:
有:
但在这一点上,我没有从其他开发者或论坛上找到任何其他的证实,只是我自己。在
相关问题 更多 >
编程相关推荐