通过onclick点击事件然后通过ajax查询取值并回显碰到的坑
我要实现的是通过onclick点击事件然后通过ajax查询取值并回显数据,刚开始我以为我的ajax有问题,反复百度学习,最后认为是业务逻辑问题,处理中我直接给后台数据库查询语句固定值,然后发现前台是可以显示到数据,那问题就出在前台的数据无法传值,回过头傻呵呵的继续死磕ajax。
经过几天的奋战无果后,就去看了眼onclick事件,才猛然反应过来我传递的是字符串,不是数字,字符串是要加单引号!!!
不扯没用的,直接上码,给自己个警钟!
<td>${
user.username}</td>
<td>
<a href="#" onclick="findBydd('${user.username}')" style="text-decoration: none;"
data-toggle="modal" data-target="#findByddModal">
<span class="fa fa-bars fa-fw">${
user.username}</span>
</a>
</td>
<!-- 查看的模态框 -->
<div class="modal fade" id="findByddModal" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×