记一次ajax+模态框传值问题+thymeleaf+th:onclik的问题
代码如下,简单记录,以防忘记
<a class="btn btn-warning btn-sm" th:onclick="|get(${user.id})|" data-toggle="modal" data-target="#userModal" >
<i class="fas fa-pencil-alt">
</i>
Edit
</a>
ajax:
function get(uid) {
var id = $("#id").val()
var username = $("#username").val()
var truename = $("#truename").val()
var nickname = $("#nickname").val()
var url="/user/getUserById/"+uid
$.ajax({
url : url,
data : {id:id,username: username, truename: truename, nickname: nickname},
async : true,
success : function (data) {
$("#id").val(data.id)
$('#username').val(data.username)
$("#truename").val(data.truename)
$("#nickname").val(data.nickname)
// $('#userModal').modal('show')
},
dataType : "json"
});
};
不经一番彻骨寒,哪有梅花扑鼻香?