我正在尝试打开一个页面,但该函数没有返回。
当我点击按钮时,该功能有效,但render_template
没有发生,我仍然在上一页
<script>
var from = '{{ d_from.strftime("%m/%d/%Y") }}';
var till = '{{ d_till.strftime("%m/%d/%Y") }}';
$(function () {
$("#reservation").daterangepicker({
"locale": {
"format": "DD/MM/YYYY"
},
"opens": "right",
"showDropdowns": true,
"showWeekNumbers": true
}, function (start, end, label) {
from= start.format('MM/DD/YYYY');
till = end.format('MM/DD/YYYY');
});
});
$( "#go" ).click(function() {
var formData = $('#form').serialize(),
times = { d_from: from, d_till: till },
data = formData + '&' + $.param(times);
$.get('{{ url_for("reporting_backoffice.updates_report") }}', data );
});
<\script>
{% block report_block_content %}
<form id="form">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-calendar"></i></div>
<input type="text" class="form-control pull-right" id="reservation"
value="{{ d_from.strftime("%m/%d/%Y") }} - {{ d_till.strftime("%m/%d/%Y") }}">
</div>
</div>
<div class="row">
<div class="col-lg-6">
{{ wtf.form_field(form.projects, class="form-control select2") }}
</div>
</div>
</form>
<button class="btn btn-primary" id="go">{{ _("Download report") }}</button>
{% endblock %}
app.py
@app.route("/updates/", methods=["GET", "POST"])
def updates_report():
return render_template("modules/reporting/updates_report.html")
当我按下终端中的按钮时,我得到:
"GET /administration/reports/updates/?projects=1&d_from=07%2F14%2F2017&d_till=07%2F14%2F2017 HTTP/1.1" 200 -
但是如果我通过参考函数它会工作并返回<a href="{{ url_for("reporting_backoffice.updates_report") }}">"Go"</a>