注意使用了thymeleaf模板jquery要写在section里面,不然没有效果呢!!!!
ajax是用来传输数据的如果说是返回整个页面是
window.location.href="接口地址?传输参数名称="+等到的web页面值;
<section> <script> $('.aaa').click(function(){ alert(222) }) </script> </section>
原图
点击查找触发接口
<div class="grop-botton">
<button type="submit" class="b-search"><i></i>查找</button>
<button type="reset" class="b-reset"><a th:href="@{'/setting/empList'}"><i></i>重置</a></button>
</div>
或者引入外部js文件
<div class="pull-right top-button">
<button type="button" class="b-add"><i></i>xxx</button>
<button type="button" class="b-delete" onclick="delSelectEmp();" value="0"><i></i>xxx</button>
</div>
js如下
<script> $('.b-search').click(function () { var test = $(this).text(); alert(test); }) </script>
完整版本:返回页面
<script>
$('.b-search').click(function () {
var areaCode = $(this).text();//this效果类同与$('.b-search').text()
alert(areaCode);
window.location.href="/customer/myChannel?areCode="+areaCode;
})
</script>
现在后台要接受参数了,可能会出现areaCode传入是null的情况
可以加
@RequestParam或者@ModelAttribute 标签接收参数