Jquery string not displaying

224 views Asked by At

I have this variable called "questionList", which is an array of objects, in which I have several strings (lets say they are called answer1, answer2...) that it's been passed from the backend to the frontend. In the actual jsp, I want to visualize the strings that are stored each of the object by using a counter, something like this lets say:

Not working -> $("#main").html("<c:set var="answer1" scope="page" value="${questionList[count].answer1}"/>");

Problem is that when I try to use it the strings are not been displayed in the frontend. However, if I instead of using a counter I use an integer it works perfectly, but of course this is not the correct way to do it.

Working -> $("#main").html("<c:set var="answer1" scope="page" value="${questionList[0].answer1}"/>");

Any idea of why this ain't working at all using a counter ? And a possible way to actually fix the issue ?

1

There are 1 answers

0
kkbur On

Did you check that count variable has an integer type? If you parse it from the page like attribute or smth like that, you might to use parseInt(var)