0

I'm trying to open a page, and the function does not return. When I click on the button, the function works, but the render_template does not happen and I remain on the previous page

<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")

When I press a button in the terminal, I get: "GET /administration/reports/updates/?projects=1&d_from=07%2F14%2F2017&d_till=07%2F14%2F2017 HTTP/1.1" 200 -

But if I go through the reference function it works and returns <a href="{{ url_for("reporting_backoffice.updates_report") }}">"Go"</a>

John
  • 117
  • 10

0 Answers0