How can I pass a variable value from a template using JavaScript without using a form (GET OR POST)?
如何在不使用表单的情况下使用JavaScript从模板传递变量值(GET或POST)?
1 个解决方案
#1
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.
您可以通过Xml Http Request从JavaScript发送此值而不使用表单 - 请参阅AJAX的工作原理。请参阅例如使用jQuery JS库的POST请求。
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.
uri参数是Django视图的URI,data - 您发送给服务器的JS对象,最后是回调 - 用于处理服务器响应的JS函数。
#1
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.
您可以通过Xml Http Request从JavaScript发送此值而不使用表单 - 请参阅AJAX的工作原理。请参阅例如使用jQuery JS库的POST请求。
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.
uri参数是Django视图的URI,data - 您发送给服务器的JS对象,最后是回调 - 用于处理服务器响应的JS函数。