Thymeleaf,将对象发送到ajax

I use spring mvc and thymeleaf and I received model object, so I have something like that :

<li th:each="game : ${availableGames}">
      <a class="gameLink" href="#" th:text="${game.getId()}" th:object="${game}"/>
</li>

How to use this object in ajax and send it to controller ? I tried this

  var ob = $(this).object()
  data : JSON.stringify(ob.JSON()),
  contentType: 'application/json',

but it isn't working

Like in tutorial you can pass object to JS variable this way:

var games = /*[[${availableGames}]]*/ null;

If you want to send selected game to controller you can find selected id in games array and send it using Ajax.

Hope it helps