Nazmul Hasan
Nazmul Hasan

Reputation: 7040

How might I pass a variable's value from a Django template into client-side JavaScript?

How can I pass a variable value from a template using JavaScript without using a form (GET OR POST)?

Upvotes: 1

Views: 619

Answers (1)

Alex Pavlov
Alex Pavlov

Reputation: 598

You can send this value from JavaScript via Xml Http Request without using form - see how AJAX works. See for example POST request with jQuery JS library.

The uri parameter is URI of your Django view, data - JS object that you send to server and finally callback - JS function to process server response.

Upvotes: 2

Related Questions