I want to pass a variable returned as a response to the zope template into a javascript variable in pyramid.
here's the views code :
def return_table(request):
selected = request.params.getall("selectedcategories")
return {'selected': selected}
and here's the template :
<script tal define:"selected ${selected}">
var selected = ${selected}
$.ajax({
type:"POST",
url: '/return_table.json?selectedcategories=' + selected,
async: false,
success: function (response) {
console.log(response)
}
})
</script>
But this is not working. I want to pass the value of selected into the javascript variable.