1
在SO上有一个类似的题目问题,但它确实与我的问题没有任何关系。将JQuery数组传递给Flask变量
所以,我有一些JQuery数组,我在一个函数中创建。现在,我想在同一个函数中为这些JS数组设置一些烧瓶变量。我想这样做的原因是,我然后设置一个元素的href
并路由我的用户。
下面是当前JS代码:
JQuery的
//Filter Search
$(function() {
$('#filter_search').click(function() {
var entities = JSON.parse(JSON.stringify($('#filterform').serializeObject())).checkboxes;
var data = JSON.parse(JSON.stringify($('#filterform').serializeObject())).checkboxeslower;
if(typeof data == "string") {
data = $.makeArray(data);
}
//Here I want to set Flask variables like {{entities}} and {{data}}
//Then, I will call the next line
$("#filter_search").attr('href', "{{ url_for('filter_search', entities='{0}', data='{1}'.format(entities, data))}}");
//Then, if all goes as planned, it will change the href and redirect the user to filtered_search
});
});