Hi everybody,
I'm trying to assign the t-value of a t element (in an xml file) from a javascript function.
Here is the Javascript function:
function get_country_code()
{
$.getJSON('https://api.db-ip.com/v2/free/self', function(data)
{
all_data = JSON.stringify(data, null, 2);
var country_code = all_data.split(',')[3].split(':')[1];
console.log(country_code);
});
}
While this is how I'm trying to assign my t-value, but I tried in different ways as well (changing the this keyword to window for example):
t t-set="country" t-value="this.get_country_code()"
But I always get this error:
Error while render the template KeyError: 'this' Template: website.layout
What is weird is that, when I'm debugging in the console, by typing "this.get_country_code()" my function gets executed correctly.
If you need more details just let me know! Any kind of suggestion is accepted! Thanks!