Pass JavaScript variable to Flask url_for
问题 I have an endpoint that takes a value in the url and produces some content that will be inserted into a div. I want to build the url with url_for using a JavaScript variable. However, $variable1 is passed as a string, rather than the value of variable1 . How can I pass the value of a JavaScript variable to url_for ? function myFunction() { var variable1 = "someString" $('#demo').load( "{{ url_for('addshare2', share = '$variable1') }}" ); } 回答1: You can't evaluate JavaScript in Jinja. You're