0

I'm calling a python endpoint method from javascript and when I try to pass in an additional parameter it's only working when the value is a string vs. a variable. This works:

var myData = $.post('{{ url_for("select2ResourceAutocomplete",variable='myValue') }}', function(data) {
    });

And I can get the parameter value using keypath = request.args.get('variable')

But if I have it this way it does not work, that is I can't get the parameter value:

var myValue = 'someValue'

var myData = $.post('{{ url_for("select2ResourceAutocomplete",variable=myValue) }}', function(data) {
});

Is there some way to pass the param value as a variable so it can be dynamic?

tw1742
  • 1,424
  • 4
  • 18
  • 37
  • Do you understand the difference between a string literal and a variable reference? In fact, the one that works is actually a reference to a string, while the one that doesn't is a literal. – TigerhawkT3 Jun 20 '16 at 03:46
  • And if you want to interpolate variables into strings in Python, that's [here](http://stackoverflow.com/questions/2960772/putting-a-variable-inside-a-string-python). – TigerhawkT3 Jun 20 '16 at 03:48
  • No idea what you're trying to point out or how to make the parameter for the POST call dynamic. – tw1742 Jun 20 '16 at 04:18

0 Answers0