html:
<link href="../../static/css/bootstrap.min.css" rel="stylesheet">
<script src="../../static/js/jquery.min.js"></script>
<script src="../../static/js/popper.min.js"></script>
<script src="../../static/js/bootstrap.min.js"></script>
<div class="card-body">
<p class="card-title">SQL</p>
<form class="forms-sample">
<div class="form-group">
<textarea class="form-control" id="mainSql" rows="4"></textarea>
</div>
<button id="sqlSubmit" type="btn btn-dark" class="btn btn-primary me-2">提交</button>
<button class="btn btn-light">Cancel</button>
</form>
</div>
javascript:
<script>
<!--加载文本文件-->
$(document).ready(function(){
//加载table
$("#sqlSubmit").click(function(){
bef_sql= $("#mainSql").val();
alert(bef_sql);
$.post("aj_tab",
{
bef_sql:bef_sql
},
function(data,status,xhr){
if(status=="success")
alert("Data: " + data + "\nStatus: " + status);
if(status=="error")
alert("ERROR"+xhr.status+": "+xhr.statusText);
});
});
})
</script>
python
@app.route("/aj_tab",methods=['GET','POST'])
def aj_tab():
if request.method=='POST':
print("aj_tab is running!!!")
sql=request.form.get("bef_sql")
sql=sql+'增加了'
return sql