<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<script src="https://g.csdnimg.cn/??lib/jquery/1.12.4/jquery.min.js"></script>
<body>
<input type="checkbox" checked id="1">实时更新
<br>
<textarea id="t" style="width: 100px; height: 20px;rows=10;"></textarea>
</body>
<script>
if($('#1').prop("checked")){
setInterval(function(){//让前端结果显示在textarea里面
}, 500);
}
</script>
</html>
from flask import Flask, render_template,jsonify
from threading import Thread
import time
app = Flask(__name__)
app.secret_key = 'ybssdddb'
class Config(object):
DEBUG = True
# 从配置对象中加载配置
app.config.from_object(Config)
@app.route('/', methods=['GET', 'POST'])
def index():
return render_template('ssgx.html')
@app.route('/a', methods=['GET', 'POST'])
def refresh():
data = {
't': '123',
}
return jsonify(data)
if __name__ == '__main__':
app.run()
如何做到checkbox勾选时,同步后端refresh数据,不勾选时停止?可以不用post么?