In a Javascript file scripts.js
, how do you send a variable called place
which contains information about a place (e.g. name, location, rating) to a Flask Python application.py
.
1 Answer
getJSON
. Use search
in pset8:script.js as your guide (or perhaps even your own addMarker from the same exercise).
The thought being, sending place
in a query string (think: request.args
) to a route in application.py. Much the same way search
uses parameters
to send the query string (ostensibly &q={query}
) to the search route. The data returned to the script can be as simple as a success/failure indicator.
-
isn't that for receiving a variable in javascript - how do you send one in javascript?– M. AlexCommented Aug 27, 2018 at 14:14
-
added more context to answer. Remember, this forum is CS50-centric. Perhaps searching for similar on stack overflow would cast a wider net. Commented Aug 27, 2018 at 15:56