thymeleaf:button点击事件传递参数

<button th:data-id="${id}" type="button" class="testBtn"></button>
<script>
        $(".testBtn").click(function() {
            var id = $(this).attr("data-id");//获得参数的值
            $.ajax({
                type:'get',
                url:"/test",
                data:{id:id},
                success:function (result) {
                    if(result ==="ok"){
                        window.location.href="/main";
                    }
                }
            });
        });
</script>
posted @ 2020-04-21 10:58  神无二一  阅读(4805)  评论(0编辑  收藏  举报