flask - python jinja2 如何从获取javascript function(_index) 传过来的参数 index?
迷茫
迷茫 2017-04-18 10:24:59
0
2
533
  1. python flask jinja2 如何从获取javascript 传过来的参数

  2. 如下代码

<script>
function itemEdit(_index) {
    console.log("index = " + _index);
    {% set index = _index %}
    var title_name = '{{ datas[index].title_name }}';
    console.log("title_name" + title_name);
    }
</script>

其中的_index 如何赋值给 index ,使得我可以获取datas[index] 这个item
或许我写的不对,但是想要的结果就是如何获取传进来的参数
希望有大神能够解答

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
Ty80

If I understand correctly, you want to write the data directly in the function. You can use the safe filter.

<script> function itemEdit(_index) {
        console.log("index = " + _index);
        var title_name = {{datas | safe }}[_index].title_name;
        console.log("title_name" + title_name);
    }
</script>
小葫芦

Make good use of search engines...
Why Python Flask jQuery AJAX?
Data interaction between front-end and back-end (jquery ajax+python flask)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template