注册-异步请求
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>login</title> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script> </head> <body> <form action="login.do"> 用户 名:<input name="name" type="text" onblur="checkNameFun()"/><span id="namespan"></span><br/> 密 码:<input name="password1" type="password" /> 确认密码:<input name="password2" type="password" /> <input type="submit" value="确定"/> </form> </body> <script type="text/javascript"> function checkNameFun(){ $.ajax({ "type": "GET", "url": "${pageContext.request.contextPath}/checkName.do", "data": "name=gjack", "dataType":"json", "success": function(data){ alert(data.message); $("#namespan").html(data.message); } }); } </script> </html>
今日事今日毕