Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用django模板变量作为参数来调用javascript函数?_Javascript_Django_Django Templates_Arguments - Fatal编程技术网

如何使用django模板变量作为参数来调用javascript函数?

如何使用django模板变量作为参数来调用javascript函数?,javascript,django,django-templates,arguments,Javascript,Django,Django Templates,Arguments,1.这是我调用changeButton的html代码,changeButton是javascript函数 <a href="#" class="btn btn-primary btn-sm" href="#" onclick="changeButton( "{{ request.session.variable }}" );return false;">Button</a> 三,。参数::request.session.variable的值为:joe 我得到一个错误:

1.这是我调用changeButton的html代码,changeButton是javascript函数

 <a href="#" class="btn btn-primary btn-sm" href="#" onclick="changeButton( "{{ request.session.variable }}" );return false;">Button</a>
三,。参数::request.session.variable的值为:joe

我得到一个错误: 1.SyntaxError:如果我以双引号“{request.session.variable}}”2传递参数,则出现语法错误。如果没有qoutes{{request.session.variable}}ReferenceError:joe未定义

请尝试此操作

<a href="#" class="btn btn-primary btn-sm" href="#" onclick="changeButton( '{{ request.session.variable }}' );return false;">Button</a>

“{request.session.variable}}”

<a href="#" class="btn btn-primary btn-sm" href="#" onclick="changeButton( '{{ request.session.variable }}' );return false;">Button</a>