Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing data from javascript into Flask

I know how to pass data with a jinja template from python into javascript, but I want to pass a javascript variable into python. I'd like to do it without reloading the page. Is that possible?

like image 888
blueintegral Avatar asked Mar 21 '13 00:03

blueintegral


People also ask

How do you pass a JavaScript variable to a python Flask?

Passing a JavaScript Variable to a Python variable in Flask First, we will be forming our HTML page, with a basic input area and JavaScript function to pass the value along. We have an onclick() function that is calling our senduserinfo() JavaScript function.

Can Flask be used with JavaScript?

Flask is an open source tool with 45.2K GitHub stars and 12.7K GitHub forks. Here's a link to Flask's open source repository on GitHub. Airbnb, Instagram, and reddit are some of the popular companies that use JavaScript, whereas Flask is used by Netflix, reddit, and Lyft.


1 Answers

Yes, like monkut said--I believe you want to use JSON and Javascript/jQuery.

This will let allow communication from client to server and back again.

The most applicable example I found was in the Flask snippets/patterns: http://flask.pocoo.org/docs/patterns/jquery/

like image 173
Allan Anderson Avatar answered Sep 28 '22 11:09

Allan Anderson