Loading... ```java @RequestMapping(value="user") @ResponseBody public void UserJson(HttpServletResponse response,String username) throws IOException { if("test".equals(username)){ response.getWriter().print("用户名存在"); }else{ response.getWriter().print("用户名可用"); } } ``` ```javascript <script> $(document).ready(function() { $("#username").blur(function() { $.ajax({//ajax请求 type : 'post',//请求方法 url : 'user',//请求路径 data : {username:$("#username").val()},//json格式数据 success : function(data) {//回调函数 $("#user_result").text(data) } }); }); }); </script> ``` ```html <label for="username">用户名: </label><input id="username" type="text" name="username"/><span id="user_result"></span> ``` Last modification:December 26, 2020 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 感谢大佬投喂 啾咪~