Reputation: 2070
Got this session variable in a html template :
request.session["rer_value"]
And i need to call it inside a jquery code that is located in another html template to make some calculations:
vrer= request.session["rer_value"];
$('table').on('change', '.usd_value', function() {
pesos_value = $(this).closest('tr').find('.pesos_value');
percent = $(this).closest('tr').find('.percent');
//$(pesos_value).val($(this).val() * vrer);
});
But itś not working....any idea ?, thanks for your help !!
Upvotes: 0
Views: 2470
Reputation: 599580
That isn't going to work, is it, because request.session
is an object on the server, not in the client-side Javascript.
If you want to make that value available for jQuery to use, you will need to pass it explicitly into the template from the view.
in your view:
return render(request, 'mytemplate.html', {'vrer': request.session["rer_value"], ...})
in your template:
var vrer = "{{ vrer }}"
Upvotes: 2