0

I can't comeup the terminology: what is the "answer" that the server sends to Get method? It builds the HTML document, but how it's called? Answer document?

I'm trying to find how i can get the html value (rname in this situation) to javascript. My server makes this html "welcome ... " text, but now i would need to reuse that name in javascript (at the same page).

<h1> Welcome {{rname}} </h1>

How i can assign rname to javascript variable?

I found this solution, but it seems way over complicated to just read one "variable" Passing variables from Flask to JavaScript

0

2 Answers 2

1

somewhere in your html template you can assign that value to a global js variable:

<h1> Welcome {{rname}} </h1>
<script>
  var username = {{rname}};
</script>

EDIT: to avoid conflicts, since this is a global variable, you might want to give it a more unique name like global_username

Sign up to request clarification or add additional context in comments.

Comments

1

It is called response and you could get variables from response by res.something. But you need to specify which technology you use for communicating with your server.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.