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

KaMa
  • 25
  • 4

2 Answers2

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

brein
  • 1,409
  • 9
  • 11
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.

Gerpstarg
  • 125
  • 7