I want to pass Thymleaf variable to a javascript function. My Thymleaf portion is like this
<a class="cat-title" th:onclick="|fetchProduct('${category.categoryId}','${businessId}')|">
<p th:text="${category.name}"></a>
And my javascript code is like this
function fetchProduct(businessId,categoryId) {
var productUrl = '/webstore/business/' + businessId + '/category/' + categoryId + '/products';
............
............
}
But when I load the page I get this error
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Only variable expressions returning numbers or booleans are allowed in this context, any other datatypes are not trusted in the context of this expression, including Strings or any other object that could be rendered as a text literal.
What is the reason for this error?