-1

I want to reload a calendar by changing the year by clicking on a element. My js looks like this:

var y = document.getElementById('yy').getAttribute('data-value');
$(document).ready(function(){
    $('.prev').click(function(){
        $(".main_content").empty();
        $('.main_content').load("calendar", {'year': int(yy)-1});
    });
});

How do i get the parameters on the server by using Flask?

i want to have something like this:

year = request.args.get('year')
# some more code
return render_template('calendar.html', year=year, #more params)
MaxW
  • 9
  • 2

1 Answers1

0

The data is sent with a POST request as form data. Use the request.form object to get the data.

@app.route('/calendar', methods=['GET', 'POST'])
def calendar():
    if request.method == 'POST':
        year = request.form.get('year', type=int)
        # Your code here.
        return 'Your reply here.'
    return render_template('calendar.html')
Detlef
  • 3,380
  • 2
  • 4
  • 21