记一次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"
			});
		};

 

posted @ 2020-01-26 22:22  9529  阅读(208)  评论(0编辑  收藏  举报