我一直在四处搜寻,但是我不太了解ajax的工作原理。 可否请人解释这是如何工作的?
$.ajax({
url: "{{ url_for( 'app.slideshow.' ) }}",
type: "",
data: {'param':},
dataType: "",
success : function(response)
{
}
我正在尝试做的是查看document.getElementsByClassName(current)是否已更改。如果有,它将询问app.py当前的评论和标签,并在不刷新的情况下更新页面。我也不知道该怎么写才能在app.py上收到它。
我将包含我的app.py,但这不是很好。
from flask import Flask,session,url_for,request,redirect,render_template
import api,db
app = Flask(__name__)
#app.secret_key = "secret"
@app.route('/slideshow/', methods=['GET', 'POST'])
def slide():
if request.method=="GET":
pic = request.get('current').href
taglist = db.getTaglist()
tags = db.getTags(pic)
piclist = db.getPics()
commentlist = db.getComments(pic)
return render_template("slide.html", taglist = taglist, tags =tags, piclist =piclist, commentlist = commentlist, url = url)
else:
button = request.form['button']
pic = request.get('current').href
if button=="submit":
aComment = request.form['comment']
db.addComment(pic,aComment)
elif button == "submitnewtag":
if request.form['Addnewtag']
aTag = request.form['Addnewtag']
db.addTag(pic,aTag)
else:
aTag = request.form['select1']
db.addTag(pic,aTag)
if __name__=="__main__":
app.debug=True
app.run(port=5300)