weixin_33709609 2014-05-11 12:12 采纳率: 0%
浏览 346

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

  • 写回答

1条回答 默认 最新

  • csdnceshi62 2014-05-11 21:16
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?