There's a similar titled question on SO, but it really doesn't have anything to do with my issue.
So, I have some JQuery arrays that I create in a function. Now, I would like to set some flask variables to those JS arrays in that same function. The reason I would like to do this is so that I then set the href of an element and route my user.
Here's the current JS code:
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
});
});